func WalkJSON(tree interface{}, visit func(elem interface{}) error) error
WalkJSON calls visit on all elements in a tree of decoded json
JSONContainer returns any existing child value for a given JSON property string
type JSONContainer interface { // JSONProp takes a string reference for a given JSON property. // implementations must return any matching property of that name, // nil if no such subproperty exists. // Note that implementations on slice-types are expected to convert // prop to an integer value JSONProp(prop string) interface{} }
JSONParent is an interface that enables tree traversal by listing all immediate children of an object
type JSONParent interface { // JSONChildren should return all immidiate children of this element // with json property names as keys, go types as values // Note that implementations on slice-types are expected to convert // integers to string keys JSONProps() map[string]interface{} }
Pointer represents a parsed JSON pointer
type Pointer []string
func NewPointer() Pointer
NewPointer creates a Pointer with a pre-allocated block of memory to avoid repeated slice expansions
func Parse(str string) (Pointer, error)
Parse parses str into a Pointer structure. str may be a pointer or a url string. If a url string, Parse will use the URL's fragment component (the bit after the '#' symbol)
func (p Pointer) Descendant(path string) (Pointer, error)
Descendant returns a new pointer to a descendant of the current pointer parsing the input path into components
func (p Pointer) Eval(data interface{}) (result interface{}, err error)
Eval evaluates a json pointer against a given root JSON document Evaluation of a JSON Pointer begins with a reference to the root value of a JSON document and completes with a reference to some value within the document. Each reference token in the JSON Pointer is evaluated sequentially.
func (p Pointer) Head() *string
Head returns the root of the Pointer
func (p Pointer) IsEmpty() bool
IsEmpty is a utility function to check if the Pointer is empty / nil equivalent
func (p Pointer) RawDescendant(path ...string) Pointer
RawDescendant extends the pointer with 1 or more path tokens The function itself is unsafe as it doesnt fully parse the input and assumes the user is directly managing the pointer This allows for much faster pointer management
func (p Pointer) String() (str string)
String implements the stringer interface for Pointer, giving the escaped string
func (p Pointer) Tail() Pointer
Tail returns everything after the Pointer head