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 ¶
Constants ¶
This section is empty.
Variables ¶
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",
}
Functions ¶
This section is empty.
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 ¶
type FilterNode struct {
NodeType
Left *ListNode
Right *ListNode
Operator string
}
FilterNode holds operand and operator information for filter
type IdentifierNode ¶
type IdentifierNode struct {
NodeType
Name string
}
IdentifierNode holds an identifier
type JSONPath ¶
type JSONPath struct {
// contains filtered or unexported fields
}
func (*JSONPath) Execute ¶
func (j *JSONPath) Execute(wr io.Writer, data interface{}) error
Execute bounds data into template and write the result
func (*JSONPath) FindResults ¶
func (j *JSONPath) FindResults(data interface{}) ([][]reflect.Value, error)
func (*JSONPath) Parse ¶
func (j *JSONPath) Parse(text string) (err error)
Parse parse the given template, return error
func (*JSONPath) PrintResults ¶
func (j *JSONPath) PrintResults(wr io.Writer, results []reflect.Value) error
PrintResults write the results into writer
type ListNode ¶
type ListNode struct {
NodeType
Nodes []Node // The element nodes in lexical order.
}
ListNode holds a sequence of nodes.
type NodeType ¶
type NodeType int
NodeType identifies the type of a parse tree node.
const (
NodeText NodeType = iota
NodeArray
NodeList
NodeField
NodeIdentifier
NodeFilter
NodeInt
NodeFloat
NodeWildcard
NodeRecursive
NodeUnion
)
type ParamsEntry ¶
type ParamsEntry struct {
Value int
Known bool //whether the value is known when parse it
}
ParamsEntry holds param information for ArrayNode
type Parser ¶
type Parser struct {
Name string
Root *ListNode
// contains filtered or unexported fields
}
type RecursiveNode ¶
type RecursiveNode struct {
NodeType
}
RecursiveNode means a recursive descent operator
type TextNode ¶
type TextNode struct {
NodeType
Text string // The text; may span newlines.
}
TextNode holds plain text.
type UnionNode ¶
type UnionNode struct {
NodeType
Nodes []*ListNode
}
UnionNode is union of ListNode