client-go: k8s.io/client-go/util/jsonpath Index | Files

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

Package Files

doc.go jsonpath.go node.go parser.go

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",
}

func UnquoteExtend Uses

func UnquoteExtend(s string) (string, error)

UnquoteExtend is almost same as strconv.Unquote(), but it support parse single quotes as a string

type ArrayNode Uses

type ArrayNode struct {
    NodeType
    Params [3]ParamsEntry // start, end, step
}

ArrayNode holds start, end, step information for array index selection

func (*ArrayNode) String Uses

func (a *ArrayNode) String() string

type BoolNode Uses

type BoolNode struct {
    NodeType
    Value bool
}

BoolNode holds bool value

func (*BoolNode) String Uses

func (b *BoolNode) String() string

type FieldNode Uses

type FieldNode struct {
    NodeType
    Value string
}

FieldNode holds field of struct

func (*FieldNode) String Uses

func (f *FieldNode) String() string

type FilterNode Uses

type FilterNode struct {
    NodeType
    Left     *ListNode
    Right    *ListNode
    Operator string
}

FilterNode holds operand and operator information for filter

func (*FilterNode) String Uses

func (f *FilterNode) String() string

type FloatNode Uses

type FloatNode struct {
    NodeType
    Value float64
}

FloatNode holds float value

func (*FloatNode) String Uses

func (i *FloatNode) String() string

type IdentifierNode Uses

type IdentifierNode struct {
    NodeType
    Name string
}

IdentifierNode holds an identifier

func (*IdentifierNode) String Uses

func (f *IdentifierNode) String() string

type IntNode Uses

type IntNode struct {
    NodeType
    Value int
}

IntNode holds integer value

func (*IntNode) String Uses

func (i *IntNode) String() string

type JSONPath Uses

type JSONPath struct {
    // contains filtered or unexported fields
}

func New Uses

func New(name string) *JSONPath

New creates a new JSONPath with the given name.

func (*JSONPath) AllowMissingKeys Uses

func (j *JSONPath) AllowMissingKeys(allow bool) *JSONPath

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) Execute Uses

func (j *JSONPath) Execute(wr io.Writer, data interface{}) error

Execute bounds data into template and writes the result.

func (*JSONPath) FindResults Uses

func (j *JSONPath) FindResults(data interface{}) ([][]reflect.Value, error)

func (*JSONPath) Parse Uses

func (j *JSONPath) Parse(text string) error

Parse parses the given template and returns an error.

func (*JSONPath) PrintResults Uses

func (j *JSONPath) PrintResults(wr io.Writer, results []reflect.Value) error

PrintResults writes the results into writer

type ListNode Uses

type ListNode struct {
    NodeType
    Nodes []Node // The element nodes in lexical order.
}

ListNode holds a sequence of nodes.

func (*ListNode) String Uses

func (l *ListNode) String() string

type Node Uses

type Node interface {
    Type() NodeType
    String() string
}

type NodeType Uses

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 Uses

func (t NodeType) String() string

func (NodeType) Type Uses

func (t NodeType) Type() NodeType

Type returns itself and provides an easy default implementation

type ParamsEntry Uses

type ParamsEntry struct {
    Value int
    Known bool // whether the value is known when parse it
}

ParamsEntry holds param information for ArrayNode

type Parser Uses

type Parser struct {
    Name string
    Root *ListNode
    // contains filtered or unexported fields
}

func NewParser Uses

func NewParser(name string) *Parser

func Parse Uses

func Parse(name, text string) (*Parser, error)

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 Uses

func (p *Parser) Parse(text string) error

type RecursiveNode Uses

type RecursiveNode struct {
    NodeType
}

RecursiveNode means a recursive descent operator

func (*RecursiveNode) String Uses

func (r *RecursiveNode) String() string

type TextNode Uses

type TextNode struct {
    NodeType
    Text string // The text; may span newlines.
}

TextNode holds plain text.

func (*TextNode) String Uses

func (t *TextNode) String() string

type UnionNode Uses

type UnionNode struct {
    NodeType
    Nodes []*ListNode
}

UnionNode is union of ListNode

func (*UnionNode) String Uses

func (u *UnionNode) String() string

type WildcardNode Uses

type WildcardNode struct {
    NodeType
}

WildcardNode means a wildcard

func (*WildcardNode) String Uses

func (i *WildcardNode) String() string

Package jsonpath imports 11 packages (graph) and is imported by 55 packages. Updated 2018-04-20. Refresh now. Tools for package owners.