Documentation
¶
Overview ¶
Package jp provides JSONPath implementation that operations on simple go types, generic (gen package), and public struct with public members. Get, set, and delete operations can be evaluated on data. When needed reflection is used to follow a path.
Index ¶
- Variables
- func AppendString(buf []byte, s string, delim byte) []byte
- func PathMatch(target, path Expr) bool
- func RegisterBinaryFunction(name string, getLeft, getRight bool, f func(left, right any) any)
- func RegisterUnaryFunction(name string, get bool, f func(arg any) any)
- func Walk(data any, cb func(path Expr, value any), justLeaves ...bool)
- type At
- type Bracket
- type Child
- type Descent
- type Equation
- func Add(left, right *Equation) *Equation
- func And(left, right *Equation) *Equation
- func ConstBool(b bool) *Equation
- func ConstFloat(f float64) *Equation
- func ConstInt(i int64) *Equation
- func ConstList(list []any) *Equation
- func ConstNil() *Equation
- func ConstNothing() *Equation
- func ConstRegex(rx *regexp.Regexp) *Equation
- func ConstString(s string) *Equation
- func Count(x Expr) *Equation
- func Divide(left, right *Equation) *Equation
- func Empty(left, right *Equation) *Equation
- func Eq(left, right *Equation) *Equation
- func Exists(left, right *Equation) *Equation
- func Get(x Expr) *Equation
- func Gt(left, right *Equation) *Equation
- func Gte(left, right *Equation) *Equation
- func Has(left, right *Equation) *Equation
- func In(left, right *Equation) *Equation
- func Length(x Expr) *Equation
- func Lt(left, right *Equation) *Equation
- func Lte(left, right *Equation) *Equation
- func Match(left, right *Equation) *Equation
- func Multiply(left, right *Equation) *Equation
- func MustParseEquation(str string) (eq *Equation)
- func Neq(left, right *Equation) *Equation
- func Not(arg *Equation) *Equation
- func Or(left, right *Equation) *Equation
- func Regex(left, right *Equation) *Equation
- func Search(left, right *Equation) *Equation
- func Sub(left, right *Equation) *Equation
- type Expr
- func A() Expr
- func B() Expr
- func C(key string) Expr
- func D() Expr
- func F(e *Equation) Expr
- func MustParse(buf []byte) (x Expr)
- func MustParseString(s string) (x Expr)
- func N(n int) Expr
- func Parse(buf []byte) (x Expr, err error)
- func ParseString(s string) (x Expr, err error)
- func R() Expr
- func S(start int, rest ...int) Expr
- func U(keys ...any) Expr
- func W() Expr
- func X() Expr
- func (x Expr) A() Expr
- func (x Expr) Append(buf []byte, brackets ...bool) []byte
- func (x Expr) At() Expr
- func (x Expr) B() Expr
- func (x Expr) BracketString() string
- func (x Expr) C(key string) Expr
- func (x Expr) Child(key string) Expr
- func (x Expr) D() Expr
- func (x Expr) Del(data any) error
- func (x Expr) DelOne(data any) error
- func (x Expr) Descent() Expr
- func (x Expr) F(e *Equation) Expr
- func (x Expr) Filter(e *Equation) Expr
- func (x Expr) First(data any) any
- func (x Expr) FirstFound(data any) (any, bool)
- func (x Expr) FirstNode(n gen.Node) (result gen.Node)
- func (x Expr) Get(data any) (results []any)
- func (x Expr) GetNodes(n gen.Node) (results []gen.Node)
- func (x Expr) Has(data any) bool
- func (x Expr) Locate(data any, max int) (locs []Expr)
- func (x Expr) Modify(data any, modifier func(element any) (altered any, changed bool)) (result any, err error)
- func (x Expr) ModifyOne(data any, modifier func(element any) (altered any, changed bool)) (result any, err error)
- func (x Expr) MustDel(data any)
- func (x Expr) MustDelOne(data any)
- func (x Expr) MustModify(data any, modifier func(element any) (altered any, changed bool)) any
- func (x Expr) MustModifyOne(data any, modifier func(element any) (altered any, changed bool)) any
- func (x Expr) MustRemove(data any) any
- func (x Expr) MustRemoveOne(data any) any
- func (x Expr) MustSet(data, value any)
- func (x Expr) MustSetOne(data, value any)
- func (x Expr) N(n int) Expr
- func (x Expr) Normal() bool
- func (x Expr) Nth(n int) Expr
- func (x Expr) R() Expr
- func (x Expr) Remove(data any) (result any, err error)
- func (x Expr) RemoveOne(data any) (result any, err error)
- func (x Expr) Root() Expr
- func (x Expr) S(start int, rest ...int) Expr
- func (x Expr) Set(data, value any) error
- func (x Expr) SetOne(data, value any) error
- func (x Expr) Slice(start int, rest ...int) Expr
- func (x Expr) String() string
- func (x Expr) U(keys ...any) Expr
- func (x Expr) Union(keys ...any) Expr
- func (x Expr) W() Expr
- func (x Expr) Walk(data any, cb func(path Expr, nodes []any))
- func (x Expr) Wildcard() Expr
- type Filter
- type Form
- type Frag
- type Indexed
- type Keyed
- type MatchHandler
- func (h *MatchHandler) AddValue(v any)
- func (h *MatchHandler) ArrayEnd()
- func (h *MatchHandler) ArrayStart()
- func (h *MatchHandler) Bool(v bool)
- func (h *MatchHandler) Float(v float64)
- func (h *MatchHandler) Int(v int64)
- func (h *MatchHandler) Key(k string)
- func (h *MatchHandler) Null()
- func (h *MatchHandler) Number(num string)
- func (h *MatchHandler) ObjectEnd()
- func (h *MatchHandler) ObjectStart()
- func (h *MatchHandler) String(v string)
- type Nth
- type Proc
- type Procedure
- type RemovableIndexed
- type Root
- type Script
- type Slice
- type TargetRest
- type Union
- type Wildcard
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var CompileScript func(code []byte) Procedure
CompileScript if non-nil should return object that implments the Procedure interface. This function is called when a script notation bracketed by [( and )] is encountered. Note the string code argument will included the open and close parenthesis but not the square brackets.
var ( // Nothing can be used in scripts to indicate no value as in a script such // as [?(@.x == Nothing)] this indicates there was no value as @.x. It is // the same as [?(@.x has false)] or [?(@.x exists false)]. Nothing = nothing(0) )
Functions ¶
func AppendString ¶ added in v1.18.2
AppendString to a buffer while escaping characters as necessary.
func PathMatch ¶ added in v1.24.0
PathMatch returns true if the provided path would match the target expression. The path argument is expected to be a normalized path with only elements of Root ($), At (@), Child (string), or Nth (int). A Filter fragment in the target expression will match any value in path since it requires data from a JSON document to be evaluated. Slice fragments always return true as long as the path element is an Nth.
func RegisterBinaryFunction ¶ added in v1.23.0
RegisterBinaryFunction registers a function that takes two argument for scripts. The 'getLeft' and 'getRight' arguments if true indicates a get operation to provide the argument to the provided function otherwise the first match is used. Names must be alpha characters only.
func RegisterUnaryFunction ¶ added in v1.23.0
RegisterUnaryFunction registers a unary function for scripts. The 'get' argument if true indicates a get operation to provide the argument to the provided function otherwise the first match is used. Names must be alpha characters only.
Types ¶
type At ¶
type At byte
At is the @ in a JSON path representation.
type Bracket ¶
type Bracket byte
Bracket is used as a flag to indicate the path should be displayed in a bracketed representation.
type Child ¶
type Child string
Child is a child operation for a JSON path expression.
type Descent ¶
type Descent byte
Descent is used as a flag to indicate the path should be displayed in a recursive descent representation.
type Equation ¶
type Equation struct {
// contains filtered or unexported fields
}
Equation represents JSON Path script and filter equations. They are used to build a script. The purpose of the Equation is to allow scripts or filters to be created without using a parser which could return an error if an invalid string representation of the script is provided.
func ConstFloat ¶
ConstFloat creates and returns an Equation for a float64 constant.
func ConstNil ¶
func ConstNil() *Equation
ConstNil creates and returns an Equation for a constant of nil.
func ConstNothing ¶ added in v1.18.0
func ConstNothing() *Equation
ConstNothing creates and returns an Equation for a constant of nothing.
func ConstRegex ¶ added in v1.14.0
ConstRegex creates and returns an Equation for a regex constant.
func ConstString ¶
ConstString creates and returns an Equation for a string constant.
func MustParseEquation ¶ added in v1.21.3
MustParseEquation parses the string argument and returns an Equation or panics.
type Expr ¶
type Expr []Frag
Expr is a JSON path expression composed of fragments. An Expr implements JSONPath as described by https://goessner.net/articles/JsonPath. Where the definition is unclear Oj has implemented the description based on the best judgement of the author.
Example (Noparse) ¶
package main
import (
"fmt"
"github.com/ohler55/ojg/jp"
"github.com/ohler55/ojg/oj"
)
func main() {
data := map[string]any{
"a": []any{
map[string]any{"x": 1, "y": 2, "z": 3},
map[string]any{"x": 1, "y": 4, "z": 9},
},
"b": []any{
map[string]any{"x": 4, "y": 5, "z": 6},
map[string]any{"x": 16, "y": 25, "z": 36},
},
}
x := jp.C("b").F(jp.Gt(jp.Get(jp.A().C("y")), jp.ConstInt(10))).C("x")
fmt.Println(x.String())
result := x.Get(data)
fmt.Println(oj.JSON(result, &oj.Options{Sort: true}))
}
Output: b[?(@.y > 10)].x [16]
func MustParseString ¶ added in v1.11.0
MustParseString parses a string into an Expr and panics on error.
Example ¶
package main
import (
"fmt"
"github.com/ohler55/ojg/jp"
"github.com/ohler55/ojg/oj"
)
func main() {
data := map[string]any{
"a": []any{
map[string]any{"x": 1, "y": 2, "z": 3},
map[string]any{"x": 1, "y": 4, "z": 9},
},
"b": []any{
map[string]any{"x": 4, "y": 5, "z": 6},
map[string]any{"x": 16, "y": 25, "z": 36},
},
}
x := jp.MustParseString("b[?(@.y > 10)].x")
fmt.Println(x.String())
result := x.Get(data)
fmt.Println(oj.JSON(result))
}
Output: b[?(@.y > 10)].x [16]
func ParseString ¶
ParseString parses a string into an Expr.
Example ¶
package main
import (
"fmt"
"github.com/ohler55/ojg/jp"
"github.com/ohler55/ojg/oj"
)
func main() {
data := map[string]any{
"a": []any{
map[string]any{"x": 1, "y": 2, "z": 3},
map[string]any{"x": 1, "y": 4, "z": 9},
},
"b": []any{
map[string]any{"x": 4, "y": 5, "z": 6},
map[string]any{"x": 16, "y": 25, "z": 36},
},
}
x, err := jp.ParseString("b[?(@.y > 10)].x")
if err != nil {
fmt.Println(err.Error())
return
}
fmt.Println(x.String())
result := x.Get(data)
fmt.Println(oj.JSON(result))
}
Output: b[?(@.y > 10)].x [16]
func (Expr) Append ¶
Append a string representation of the expression to a byte slice and return the expanded buffer.
func (Expr) BracketString ¶ added in v1.21.0
BracketString returns a string representation of the expression using the bracket notation.
func (Expr) Del ¶
Del removes matching nodes.
Example ¶
package main
import (
"fmt"
"github.com/ohler55/ojg"
"github.com/ohler55/ojg/jp"
"github.com/ohler55/ojg/sen"
)
func main() {
data := []any{
map[string]any{"a": 1, "b": 2, "c": 3},
}
if err := jp.N(0).C("b").Del(data); err != nil {
panic(err)
}
fmt.Println(sen.String(data, &ojg.Options{Sort: true}))
}
Output: [{a:1 c:3}]
func (Expr) FirstFound ¶ added in v1.18.0
FirstFound element of the data identified by the path.
func (Expr) Has ¶ added in v1.13.0
Has returns true if there is a value ot the end of the path specified. A nil value is still a value.
func (Expr) Locate ¶ added in v1.21.0
Locate the values described by the Expr and return a slice of normalized paths to those values in the data. The returned slice is limited to the max specified. A max of 0 or less indicates there is no maximum.
func (Expr) Modify ¶ added in v1.17.0
func (x Expr) Modify(data any, modifier func(element any) (altered any, changed bool)) (result any, err error)
Modify modifies matching nodes and panics on an expression error. Modified elements replace the original element in the data. The modified data is returned. Unless the data is a slice and modified the returned data will be the same object as the original. The modifier function will be called with the elements that match the path and should return the original element or if altered the altered value along with setting the returned changed value to true.
func (Expr) ModifyOne ¶ added in v1.17.0
func (x Expr) ModifyOne(data any, modifier func(element any) (altered any, changed bool)) (result any, err error)
ModifyOne modifies matching nodes and panics on an expression error. Modified elements replace the original element in the data. The modified data is returned. Unless the data is a slice and modified the returned data will be the same object as the original. The modifier function will be called with the elements that match the path and should return the original element or if altered the altered value along with setting the returned changed value to true. The function returns after the first modification.
func (Expr) MustDel ¶ added in v1.11.0
MustDel removes matching nodes and panics on error.
Example ¶
package main
import (
"fmt"
"github.com/ohler55/ojg"
"github.com/ohler55/ojg/jp"
"github.com/ohler55/ojg/sen"
)
func main() {
data := []any{
map[string]any{"a": 1, "b": 2, "c": 3},
}
jp.N(0).C("b").MustDel(data)
fmt.Println(sen.String(data, &ojg.Options{Sort: true}))
}
Output: [{a:1 c:3}]
func (Expr) MustDelOne ¶ added in v1.16.0
MustDelOne removes one matching node and panics on error.
func (Expr) MustModify ¶ added in v1.17.0
MustModify modifies matching nodes and panics on an expression error. In go, maps can be modified in place as the map itself is modified. Slice elements can be replaced in place but elements can not be added or removed without potentially needing to replace the original slice with a new one. This function and the other jp.Modify functions allow a slice to be replaced by stopping at the parent of the target slice and applying a modifier function to the target which is then replaced in the parent. Without that functionality slice element can only be replaced.
Modified elements replace the original element in the data. The modified data is returned. Unless the data is a slice and modified the returned data will be the same object as the original. The modifier function will be called with the elements that match the path and should return the original element or if altered the altered value along with setting the returned changed value to true.
func (Expr) MustModifyOne ¶ added in v1.17.0
MustModifyOne modifies matching nodes and panics on an expression error. Modified elements replace the original element in the data. The modified data is returned. Unless the data is a slice and modified the returned data will be the same object as the original. The modifier function will be called with the elements that match the path and should return the original element or if altered the altered value along with setting the returned changed value to true. The function returns after the first modification.
func (Expr) MustRemove ¶ added in v1.16.0
MustRemove removes matching nodes and panics on an expression error but silently makes no changes if there is no match for the expression. Removed slice elements are removed and the remaining elements are moveed to fill in the removed element. The slice is shortened.
func (Expr) MustRemoveOne ¶ added in v1.16.0
MustRemoveOne removes matching nodes and panics on an expression error but silently makes no changes if there is no match for the expression. Removed slice elements are removed and the remaining elements are moveed to fill in the removed element. The slice is shortened.
func (Expr) MustSet ¶ added in v1.11.0
MustSet all matching child node values. If the path to the child does not exist array and map elements are added. Panics on error.
Example ¶
package main
import (
"fmt"
"github.com/ohler55/ojg"
"github.com/ohler55/ojg/jp"
"github.com/ohler55/ojg/sen"
)
func main() {
data := []any{
map[string]any{"a": 1, "b": 2, "c": 3},
}
// Set members with a JSONPath expression.
jp.N(0).C("b").MustSet(data, 7)
fmt.Println(sen.String(data, &ojg.Options{Sort: true}))
// Add members with a JSONPath expression.
jp.N(0).C("d").MustSet(data, 4)
fmt.Println(sen.String(data, &ojg.Options{Sort: true}))
}
Output: [{a:1 b:7 c:3}] [{a:1 b:7 c:3 d:4}]
func (Expr) MustSetOne ¶ added in v1.16.0
MustSetOne child node value. If the path to the child does not exist array and map elements are added. Panics on error.
func (Expr) Normal ¶ added in v1.21.2
Normal returns true if the only fragments in the expression are root, at, child, and nth.
func (Expr) Remove ¶ added in v1.16.0
Remove removes matching nodes. An error is returned for an expression error but silently makes no changes if there is no match for the expression. Removed slice elements are removed and the remaining elements are moveed to fill in the removed element. The slice is shortened.
func (Expr) RemoveOne ¶ added in v1.16.0
RemoveOne removes at most one node. An error is returned for an expression error but silently makes no changes if there is no match for the expression. Removed slice elements are removed and the remaining elements are moveed to fill in the removed element. The slice is shortened.
func (Expr) Set ¶
Set all matching child node values. An error is returned if it is not possible. If the path to the child does not exist array and map elements are added.
Example ¶
package main
import (
"fmt"
"github.com/ohler55/ojg"
"github.com/ohler55/ojg/jp"
"github.com/ohler55/ojg/sen"
)
func main() {
data := []any{
map[string]any{"a": 1, "b": 2, "c": 3},
}
// Set members with a JSONPath expression.
if err := jp.N(0).C("b").Set(data, 7); err != nil {
panic(err)
}
fmt.Println(sen.String(data, &ojg.Options{Sort: true}))
// Add members with a JSONPath expression.
if err := jp.N(0).C("d").Set(data, 4); err != nil {
panic(err)
}
fmt.Println(sen.String(data, &ojg.Options{Sort: true}))
}
Output: [{a:1 b:7 c:3}] [{a:1 b:7 c:3 d:4}]
func (Expr) SetOne ¶
SetOne child node value. An error is returned if it is not possible. If the path to the child does not exist array and map elements are added.
type Filter ¶
type Filter struct {
Script
}
Filter is a script used as a filter.
func MustNewFilter ¶ added in v1.11.0
MustNewFilter creates a new Filter and panics on error.
type Form ¶ added in v1.15.0
type Form struct {
// Op is the operation to perform.
Op string
// Left is the left side a form. The type can be a *Form, Expr, or any of
// the simple types.
Left any
// Right is the left side a form. The type can be a *Form, Expr, or any of
// the simple types.
Right any
}
Form represents a component of a JSON Path script and filter. They are used inspect a Script or Filter. The general template for a Form is (left op right). For an operations such as not (!) the right side is left as nil. As an example a Filter fragment of [?(@.x == 3)] whould be representing in a Form as
Form{Op: "==", Left: jp.Expr{jp.At('@'), jp.Child("x")}, Right: 3}.
type Frag ¶
type Frag interface {
// Append a fragment string representation of the fragment to the buffer
// then returning the expanded buffer.
Append(buf []byte, bracket, first bool) []byte
// Walk the matching elements in tail of nodes and call cb on the matches
// or follow on to the matching if not the last fragment in an
// expression. The rest argument is the rest of the expression after this
// fragment. The path is the normalized path up to this point. The nodes
// argument is the chain of data elements to the current location.
Walk(rest, path Expr, nodes []any, cb func(path Expr, nodes []any))
// contains filtered or unexported methods
}
Frag represents a JSONPath fragment. A JSONPath expression is composed of fragments (Frag) linked together to form a full path expression.
type Indexed ¶ added in v1.18.2
type Indexed interface {
// ValueAtIndex should return the value at the provided index or nil if no
// entry exists at the index.
ValueAtIndex(index int) any
// SetValueAtIndex should set the value at the provided index.
SetValueAtIndex(index int, value any)
// Size should return the size for the collection.
Size() int
}
Indexed describes an interface for a collection that is indexed by a integers similar to a []any.
type Keyed ¶ added in v1.18.2
type Keyed interface {
// ValueForKey should return the value associated with the key or nil if
// no entry exists for the key.
ValueForKey(key string) (value any, has bool)
// SetValueForKey sets the value for a key in the collection.
SetValueForKey(key string, value any)
// RemoveValueForKey removes the value for a key in the collection.
RemoveValueForKey(key string)
// Keys should return an list of the keys for all the entries in the
// collection.
Keys() []string
}
Keyed describes an interface for a collection that is indexed by a string key similar to a map[string]any.
type MatchHandler ¶ added in v1.24.0
type MatchHandler struct {
Targets []*TargetRest
Path Expr
Stack []any
OnData func(path Expr, data any)
}
PathHandler is a TokenHandler compatible with both the oj.TokenHandler and the sen.TokenHandler. Fields are public to allow derived types to access those fields.
func NewMatchHandler ¶ added in v1.24.0
func NewMatchHandler(onData func(path Expr, data any), targets ...Expr) *MatchHandler
NewMatchHandler creates a new MatchHandler.
func (*MatchHandler) AddValue ¶ added in v1.24.0
func (h *MatchHandler) AddValue(v any)
AddValue is called when a leaf value is encountered.
func (*MatchHandler) ArrayEnd ¶ added in v1.24.0
func (h *MatchHandler) ArrayEnd()
ArrayEnd is called when a JSON array end ']' is encountered.
func (*MatchHandler) ArrayStart ¶ added in v1.24.0
func (h *MatchHandler) ArrayStart()
ArrayStart is called when a JSON array start '[' is encountered.
func (*MatchHandler) Bool ¶ added in v1.24.0
func (h *MatchHandler) Bool(v bool)
Bool is called when a JSON true or false is encountered.
func (*MatchHandler) Float ¶ added in v1.24.0
func (h *MatchHandler) Float(v float64)
Float is called when a JSON decimal is encountered that fits into a float64.
func (*MatchHandler) Int ¶ added in v1.24.0
func (h *MatchHandler) Int(v int64)
Int is called when a JSON integer is encountered.
func (*MatchHandler) Key ¶ added in v1.24.0
func (h *MatchHandler) Key(k string)
Key is called when a JSON object key is encountered.
func (*MatchHandler) Null ¶ added in v1.24.0
func (h *MatchHandler) Null()
Null is called when a JSON null is encountered.
func (*MatchHandler) Number ¶ added in v1.24.0
func (h *MatchHandler) Number(num string)
Number is called when a JSON number is encountered that does not fit into an int64 or float64.
func (*MatchHandler) ObjectEnd ¶ added in v1.24.0
func (h *MatchHandler) ObjectEnd()
ObjectEnd is called when a JSON object end '}' is encountered.
func (*MatchHandler) ObjectStart ¶ added in v1.24.0
func (h *MatchHandler) ObjectStart()
ObjectStart is called when a JSON object start '{' is encountered.
func (*MatchHandler) String ¶ added in v1.24.0
func (h *MatchHandler) String(v string)
String is called when a JSON string is encountered.
type Nth ¶
type Nth int
Nth is a subscript operator that matches the n-th element in an array for a JSON path expression.
type Proc ¶ added in v1.26.0
Proc is a script used as a procedure which is a script not limited to being a selector. While both Locate() and Walk() are supported the results may not be as expected since the procedure can modify the original data. Remove() is not supported with this fragment type.
func MustNewProc ¶ added in v1.26.0
MustNewProc creates a new Proc and panics on error.
func (*Proc) Append ¶ added in v1.26.0
Append a fragment string representation of the fragment to the buffer then returning the expanded buffer.
type Procedure ¶ added in v1.26.0
type Procedure interface {
// Get should return a list of matching in the data element.
Get(data any) []any
// First should return a single matching in the data element or nil if
// there are no matches.
First(data any) any
}
Procedure defines the interface for functions for script fragments between [( and )] delimiters.
type RemovableIndexed ¶ added in v1.24.1
type RemovableIndexed interface {
Indexed
// RemoveValueAtIndex removes an item from the collection.
RemoveValueAtIndex(index int)
}
RemovableIndexed describes an indexed collection that can remove items. Must be implemented to use Expr.Remove.
type Root ¶
type Root byte
Root represents a root $ in a JSON path representation.
type Script ¶
type Script struct {
// contains filtered or unexported fields
}
Script represents JSON Path script used in filters as well.
Example ¶
package main
import (
"fmt"
"github.com/ohler55/ojg/jp"
"github.com/ohler55/ojg/oj"
)
func main() {
data := []any{
map[string]any{"a": 1, "b": 2, "c": 3},
map[string]any{"a": int64(52), "b": 4, "c": 6},
}
// Build an Equation and generate a Script from the Equation.
s := jp.Or(
jp.Lt(jp.Get(jp.A().C("a")), jp.ConstInt(52)),
jp.Eq(jp.Get(jp.A().C("x")), jp.ConstString("cool")),
).Script()
fmt.Println(s.String())
// Normally Scripts are using in Expr (JSON paths).
result := s.Eval([]any{}, data)
fmt.Println(oj.JSON(result, &oj.Options{Sort: true}))
}
Output: (@.a < 52 || @.x == 'cool') [{"a":1,"b":2,"c":3}]
func MustNewScript ¶ added in v1.11.0
MustNewScript parses the string argument and returns a script or an error.
func (*Script) Append ¶
Append a string representation of the fragment to the buffer and then return the expanded buffer.
type Slice ¶
type Slice []int
Slice is a slice operation for a JSON path expression.
type TargetRest ¶ added in v1.24.0
type TargetRest struct {
Target Expr
// Rest is set when a Filter is included in the initializing target. Since
// Filters can only be evaluated when there is data for the evaluation a
// traget with a Filter is split with the pre-filter portion and the rest
// starting with the filter.
Rest Expr
}
TargetRest is used by the MatchHandler to associate a Target and Rest of a match search.
type Union ¶
type Union []any
Union is a union operation for a JSON path expression which is a union of a Child and Nth fragment.