jsonpath

package
v1.136.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package jsonpath reads one value out of a decoded JSON document by a path an operator writes: "$" for the document itself, ".name" or "['name']" for an object member, and "[n]" for an array element, as in "$.data.events" or "$.contact['id']" (#1870).

It is the subset of JSONPath that addresses one value. There are no wildcards, filters or recursive descent: a webhook source uses a path to find its event array, and an event's id, type and key, and each of those is one place in the document.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Scalar

func Scalar(v any) string

Scalar renders a looked-up value as the text a column stores: a string as itself, a number as written, true and false as words, null as empty, and an object or array as its compact JSON.

Types

type Path

type Path struct {
	// contains filtered or unexported fields
}

Path is a parsed path.

func Parse

func Parse(text string) (Path, error)

Parse reads a path. The leading "$" may be omitted: "data.id" is "$.data.id".

func (Path) Lookup

func (p Path) Lookup(doc any) (any, bool)

Lookup returns the value the path addresses in doc, and false when any step is missing or of the wrong kind.

func (Path) String

func (p Path) String() string

String is the path as it was written.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL