package jsonpath
import "k8s.io/client-go/util/jsonpath"
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 New(name string) *JSONPath
- func (j *JSONPath) AllowMissingKeys(allow bool) *JSONPath
- func (j *JSONPath) EnableJSONOutput(v bool)
- func (j *JSONPath) Execute(wr io.Writer, data interface{}) error
- func (j *JSONPath) FindResults(data interface{}) ([][]reflect.Value, error)
- func (j *JSONPath) Parse(text string) error
- func (j *JSONPath) PrintResults(wr io.Writer, results []reflect.Value) error
- type ListNode
- type Node
- type NodeType
- type ParamsEntry
- type Parser
- func NewParser(name string) *Parser
- func Parse(name, text string) (*Parser, error)
- func (p *Parser) Parse(text string) error
- type RecursiveNode
- type TextNode
- type UnionNode
- type WildcardNode
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", 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
func (*ArrayNode) String ¶
type BoolNode ¶
BoolNode holds bool value
func (*BoolNode) String ¶
type FieldNode ¶
FieldNode holds field of struct
func (*FieldNode) String ¶
type FilterNode ¶
FilterNode holds operand and operator information for filter
func (*FilterNode) String ¶
func (f *FilterNode) String() string
type FloatNode ¶
FloatNode holds float value
func (*FloatNode) String ¶
type IdentifierNode ¶
IdentifierNode holds an identifier
func (*IdentifierNode) String ¶
func (f *IdentifierNode) String() string
type IntNode ¶
IntNode holds integer value
func (*IntNode) String ¶
type JSONPath ¶
type JSONPath struct {
// contains filtered or unexported fields
}
func New ¶
New creates a new JSONPath with the given name.
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) EnableJSONOutput ¶
EnableJSONOutput changes the PrintResults behavior to return a JSON array of results
func (*JSONPath) Execute ¶
Execute bounds data into template and writes the result.
func (*JSONPath) FindResults ¶
func (*JSONPath) Parse ¶
Parse parses the given template and returns an error.
func (*JSONPath) PrintResults ¶
PrintResults writes the results into writer
type ListNode ¶
ListNode holds a sequence of nodes.
func (*ListNode) String ¶
type Node ¶
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 NodeBool )
func (NodeType) String ¶
func (NodeType) Type ¶
Type returns itself and provides an easy default implementation
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 ¶
func NewParser ¶
func Parse ¶
Parse parsed the given text and return a node Parser. If an error is encountered, parsing stops and an empty Parser is returned with the error
func (*Parser) Parse ¶
type RecursiveNode ¶
type RecursiveNode struct { NodeType }
RecursiveNode means a recursive descent operator
func (*RecursiveNode) String ¶
func (r *RecursiveNode) String() string
type TextNode ¶
TextNode holds plain text.
func (*TextNode) String ¶
type UnionNode ¶
UnionNode is union of ListNode
func (*UnionNode) String ¶
type WildcardNode ¶
type WildcardNode struct { NodeType }
WildcardNode means a wildcard
func (*WildcardNode) String ¶
func (i *WildcardNode) String() string
Source Files ¶
doc.go jsonpath.go node.go parser.go
- Version
- v0.33.0 (latest)
- Published
- Apr 23, 2025
- Platform
- linux/amd64
- Imports
- 12 packages
- Last checked
- 50 minutes ago –
Tools for package owners.