Documentation
¶
Overview ¶
Package jsonpath is the small JSONPath of the HTTP client's extraction rules and checks (SPEC §10.33 "Extraction and checks"): an evaluator of our own over the values encoding/json decodes, standard library only. See Compile for the syntax it supports.
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 compiled expression.
func Compile ¶
Compile reads an expression. The subset it supports is exactly this:
$ the whole document (every expression starts with it) .name the member "name" of an object (letters, digits and any characters except . [ ] ' " * and white space) ['name'] the member "name"; "name" in double quotes works too; \\ \' \" \n \t \/ and \uXXXX are escapes [n] the element n of an array, counted from 0; [-1] is the last [*] and .* every member of an object (its keys in sorted order) or every element of an array ..name the member "name" at any depth, the node itself included (..['name'], ..[n], ..[*] and ..* work the same way)
Not supported, and refused: filters ([?(...)]), slices ([1:3]), unions ([0,1]), script expressions and functions. Eval gives all the matches; an extraction rule takes the first.
func (*Path) Eval ¶
Eval gives every value the path selects in the document (a value decoded by Decode, or by encoding/json into any), in the order of the document; the members of an object are visited in the order of their sorted names. A path that selects nothing gives none.