Documentation ¶
Overview ¶
Package jsonoscope contains tooling for structural analysis of JSON documents.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CountingVisitor ¶
type CountingVisitor int
CountingVisitor tallies the number of visited nodes in a JSON tree.
func (*CountingVisitor) Enter ¶
func (cv *CountingVisitor) Enter(path string, token Token)
Enter implements the Visitor interface. It has no effect.
func (*CountingVisitor) Exit ¶
func (cv *CountingVisitor) Exit(path string, token Token, signature []byte)
Exit implements the Visitor interface. It increments the counter by one.
func (*CountingVisitor) Nodes ¶
func (cv *CountingVisitor) Nodes() int
Nodes returns the count of total visited nodes.
type CustomVisitor ¶
type CustomVisitor struct { OnEnter func(path string, token Token) OnExit func(path string, token Token, signature []byte) }
CustomVisitor is a Visitor implementation whose functionality can be dynamically configured for convenience.
func (CustomVisitor) Enter ¶
func (cv CustomVisitor) Enter(path string, token Token)
Enter implements the Visitor interface by invoking the OnEnter callback, if one exists. Otherwise this method has no effect.
type Token ¶
type Token int
Token indicates the type of the value at a given JSON path. It is always one of: Null, Number, Boolean, String, Array, or Object.
type Visitor ¶
type Visitor interface { // Enter is invoked when a node in the JSON tree is first reached. It is // supplied with the node's path and type. Enter(path string, token Token) // Enter is invoked on a node when its subtree (if any) has been fully // traversed. Invocations of Enter are matched one-to-one with calls // to Exit, and exit is provided the same token and path as Enter was. // // Exit is additionally provided with the node's signature, or a // semantically-deterministic hash of its contents. Exit(path string, token Token, signature []byte) }
Visitor defines methods that are invoked during the depth-first traversal of a JSON object.