Documentation ¶
Index ¶
- Variables
- func Find(doc DocModel, path Path) ([]any, error)
- func Join(parts ...string) string
- func MakeKeyString(input string) string
- func ParseAndFind(doc DocModel, path string) ([]any, error)
- func Search(doc DocModel, path Path, capture func(DocPath)) error
- type DocModel
- type DocPath
- type ErrInvalidExpression
- type ErrSyntax
- type MapModel
- type NodeType
- type Path
- type Segment
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoCurrentElement = errors.New("No current element") ErrInvalidAST = errors.New("Invalid AST") )
View Source
var ( SelectRootPath = Path{ // contains filtered or unexported fields } SelectCurrentPath = Path{ // contains filtered or unexported fields } WildcardPath = Path{ // contains filtered or unexported fields } )
Common path definitions
Functions ¶
func MakeKeyString ¶
MakeKeyString quotes or escapes the input string if necessary to be used in a path expression
func ParseAndFind ¶
ParseAndFind parses the path and finds matching nodes in the doc
Types ¶
type DocModel ¶
type DocModel interface { // Return the root node Root() any // Return the type of the given node Type(any) NodeType // Works on object and array nodes Len(any) int // Lookup a key in an object node Key(any, string) (any, bool) // Keys of an object node Keys(any) []string // Lookup and item in an array node Elem(any, int) any // The input is a value node. Return the value of that node Value(any) any }
DocModel represents the underlying hierarchical document model.
type DocPath ¶
type DocPath struct {
P []Segment
}
DocPath is a list of nodes of the document
func (DocPath) Index ¶
Add an array index-value to the path. The value is of type valueType. Returns the new path
func (DocPath) Key ¶
Add a key-value to the path. The value is of type valueType. Returns the new path
type ErrInvalidExpression ¶
type ErrInvalidExpression string
func (ErrInvalidExpression) Error ¶
func (e ErrInvalidExpression) Error() string
type Path ¶
type Path struct {
// contains filtered or unexported fields
}
A Path is a compiled JSONPath object.
func IndexSelectorPath ¶
Returns a path that selects an index
func RecursiveDescent ¶
Returns a new path that is a copy of p but recursively descends
Source Files ¶
Click to show internal directories.
Click to hide internal directories.