Documentation ¶
Index ¶
- Variables
- func Merge(extracters []Extracter, input map[string]interface{}) (map[string]interface{}, error)
- func MergeFields(dst, src map[string]interface{}) map[string]interface{}
- func NestedFieldNoCopy(data map[string]interface{}, allowMissingKeys bool, fields ...string) (map[string]interface{}, error)
- type ArrayNode
- type BoolNode
- type Extracter
- type FieldNode
- type FilterNode
- type FloatNode
- type IdentifierNode
- type IntNode
- type JSONPath
- type ListNode
- type NestedFieldPath
- type Node
- type Parser
- type RecursiveNode
- type TextNode
- type UnionNode
- type WildcardNode
Constants ¶
This section is empty.
Variables ¶
var Parse = jsonpath.Parse
Functions ¶
func Merge ¶
Merge is a helper function that calls all extracters and merges their outputs by calling MergeFields.
func MergeFields ¶
MergeFields merges src into dst.
Note: the merge operation on two nested list is replacing.
func NestedFieldNoCopy ¶
func NestedFieldNoCopy(data map[string]interface{}, allowMissingKeys bool, fields ...string) (map[string]interface{}, error)
NestedFieldNoCopy is similar to JSONPath.Extract. The difference is that it can only operate on map and does not support list, but has better performance.
Types ¶
type Extracter ¶
func BuildExtracter ¶
BuildExtracter automatically determines whether to use FieldPathExtracter or JSONPathExtracter. If the input jsonPath only involves map operations, it will return FieldPathExtracter, as it has better performance.
type FilterNode ¶
type FilterNode = jsonpath.FilterNode
type IdentifierNode ¶
type IdentifierNode = jsonpath.IdentifierNode
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) Extract ¶
Extract outputs the field specified by JSONPath. The output contains not only the field value, but also its upstream structure.
The data structure of the extracted field must be of type `map[string]interface{}`, and `struct` is not supported (an error will be returned).
func (*JSONPath) FindResults ¶
type NestedFieldPath ¶
type NestedFieldPath struct {
// contains filtered or unexported fields
}
NestedFieldPath is used to wrap NestedFieldNoCopy function as an Extracter.
func NewNestedFieldPath ¶
func NewNestedFieldPath(nestedField []string, allowMissingKeys bool) *NestedFieldPath
NewNestedFieldPath constructs a FieldPathExtracter.
type RecursiveNode ¶
type RecursiveNode = jsonpath.RecursiveNode
type WildcardNode ¶
type WildcardNode = jsonpath.WildcardNode