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, plus "[*]" for every element of an array, which only LookupAll reads. There are no 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. A token every item of an array must carry (Microsoft Graph's value[*].clientState, #2223) is the one place "[*]" is read.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Path ¶
type Path struct {
// contains filtered or unexported fields
}
Path is a parsed path.
func (Path) HasWildcard ¶ added in v1.152.1
HasWildcard reports whether the path steps through every element of an array ("[*]"), and so addresses many values rather than one.
func (Path) Lookup ¶
Lookup returns the value the path addresses in doc, and false when any step is missing or of the wrong kind. A "[*]" step addresses no one value, so a path holding one is never found; LookupAll reads it.
func (Path) LookupAll ¶ added in v1.152.1
LookupAll returns every value the path addresses in doc: one for a path with no "[*]", and one per element of each array a "[*]" steps through. It reports false when any step is missing or of the wrong kind for any element, and for a "[*]" over an empty array, since a value every element must carry is then carried by none.