Documentation ¶
Overview ¶
package jsonpath is a template engine using jsonpath syntax, which can be seen at http://goessner.net/articles/JsonPath/. In addition, it has {range} {end} function to iterate list and slice.
Index ¶
- Variables
- func UnquoteExtend(s string) (string, error)
- type ArrayNode
- type BoolNode
- type FieldNode
- type FilterNode
- type FloatNode
- type IdentifierNode
- type IntNode
- type JSONPath
- func (j *JSONPath) AllowMissingKeys(allow bool) *JSONPath
- func (j *JSONPath) Execute(wr io.Writer, data interface{}) error
- func (j *JSONPath) FindResults(data interface{}) ([][]Value, error)
- func (j *JSONPath) Parse(text string) error
- func (j *JSONPath) PrintResults(wr io.Writer, results []Value) error
- type ListNode
- type Node
- type NodeType
- type ParamsEntry
- type Parser
- type RecursiveNode
- type TextNode
- type UnionNode
- type Value
- type WildcardNode
Constants ¶
This section is empty.
Variables ¶
var (
ErrSyntax = errors.New("invalid syntax")
)
var NodeTypeName = map[NodeType]string{ NodeText: "NodeText", NodeArray: "NodeArray", NodeList: "NodeList", NodeField: "NodeField", NodeIdentifier: "NodeIdentifier", NodeFilter: "NodeFilter", NodeInt: "NodeInt", NodeFloat: "NodeFloat", NodeWildcard: "NodeWildcard", NodeRecursive: "NodeRecursive", NodeUnion: "NodeUnion", NodeBool: "NodeBool", }
Functions ¶
func UnquoteExtend ¶
UnquoteExtend is almost same as strconv.Unquote(), but it support parse single quotes as a string
Types ¶
type ArrayNode ¶
type ArrayNode struct { NodeType Params [3]ParamsEntry // start, end, step }
ArrayNode holds start, end, step information for array index selection
type FilterNode ¶
FilterNode holds operand and operator information for filter
func (*FilterNode) String ¶
func (f *FilterNode) String() string
type IdentifierNode ¶
IdentifierNode holds an identifier
func (*IdentifierNode) String ¶
func (f *IdentifierNode) String() string
type JSONPath ¶
type JSONPath struct {
// contains filtered or unexported fields
}
func (*JSONPath) AllowMissingKeys ¶
AllowMissingKeys allows a caller to specify whether they want an error if a field or map key cannot be located, or simply an empty result. The receiver is returned for chaining.
func (*JSONPath) FindResults ¶
type ParamsEntry ¶
type ParamsEntry struct { Value int Known bool // whether the value is known when parse it Derived bool }
ParamsEntry holds param information for ArrayNode
type Parser ¶
type RecursiveNode ¶
type RecursiveNode struct {
NodeType
}
RecursiveNode means a recursive descent operator
func (*RecursiveNode) String ¶
func (r *RecursiveNode) String() string
type Value ¶
A wrapper around reflect.Value that allows callers to call Set() on a Value retrieved from inside a map index.
In the normal reflect package, the value in a map index is not addressable, because the internal map implementation might have to rearrange the map storage.
In this implementation, we keep an extra reference to the map that "owns" the value, so that we can call Set() on it.
type WildcardNode ¶
type WildcardNode struct {
NodeType
}
WildcardNode means a wildcard
func (*WildcardNode) String ¶
func (i *WildcardNode) String() string