Documentation ¶
Overview ¶
Package jparse converts JSONata expressions to abstract syntax trees. Most clients will not need to work with this package directly.
Usage ¶
Call the Parse function, passing a JSONata expression as a string. If an error occurs, it will be of type Error. Otherwise, Parse returns the root Node of the AST.
Index ¶
- type ArrayNode
- type AssignmentNode
- type BlockNode
- type BooleanNode
- type BooleanOperator
- type BooleanOperatorNode
- type ComparisonOperator
- type ComparisonOperatorNode
- type ConditionalNode
- type DescendentNode
- type ErrType
- type Error
- type FunctionApplicationNode
- type FunctionCallNode
- type GroupNode
- type LambdaNode
- type NameNode
- type NegationNode
- type Node
- type NullNode
- type NumberNode
- type NumericOperator
- type NumericOperatorNode
- type ObjectNode
- type ObjectTransformationNode
- type Param
- type ParamOpt
- type ParamType
- type PartialNode
- type PathNode
- type PlaceholderNode
- type PredicateNode
- type RangeNode
- type RegexNode
- type SortDir
- type SortNode
- type SortTerm
- type StringConcatenationNode
- type StringNode
- type TypedLambdaNode
- type VariableNode
- type WildcardNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArrayNode ¶
type ArrayNode struct { Items []Node // contains filtered or unexported fields }
An ArrayNode represents an array of items.
type AssignmentNode ¶
An AssignmentNode represents a variable assignment.
func (*AssignmentNode) Pos ¶ added in v1.6.6
func (n *AssignmentNode) Pos() int
func (AssignmentNode) String ¶
func (n AssignmentNode) String() string
type BlockNode ¶
type BlockNode struct { Exprs []Node // contains filtered or unexported fields }
A BlockNode represents a block expression.
type BooleanNode ¶
type BooleanNode struct { Value bool // contains filtered or unexported fields }
A BooleanNode represents the boolean constant true or false.
func (*BooleanNode) Pos ¶ added in v1.6.6
func (n *BooleanNode) Pos() int
func (BooleanNode) String ¶
func (n BooleanNode) String() string
type BooleanOperator ¶
type BooleanOperator uint8
A BooleanOperator is a logical AND or OR operation between two values.
const ( BooleanAnd BooleanOperator BooleanOr )
Boolean operations supported by JSONata.
func (BooleanOperator) String ¶
func (op BooleanOperator) String() string
type BooleanOperatorNode ¶
type BooleanOperatorNode struct { Type BooleanOperator LHS Node RHS Node // contains filtered or unexported fields }
A BooleanOperatorNode represents a boolean operation.
func (*BooleanOperatorNode) Pos ¶ added in v1.6.6
func (n *BooleanOperatorNode) Pos() int
func (BooleanOperatorNode) String ¶
func (n BooleanOperatorNode) String() string
type ComparisonOperator ¶
type ComparisonOperator uint8
A ComparisonOperator is an operation that compares two values.
const ( ComparisonEqual ComparisonOperator ComparisonNotEqual ComparisonLess ComparisonLessEqual ComparisonGreater ComparisonGreaterEqual ComparisonIn )
Comparison operations supported by JSONata.
func (ComparisonOperator) String ¶
func (op ComparisonOperator) String() string
type ComparisonOperatorNode ¶
type ComparisonOperatorNode struct { Type ComparisonOperator LHS Node RHS Node // contains filtered or unexported fields }
A ComparisonOperatorNode represents a comparison operation.
func (*ComparisonOperatorNode) Pos ¶ added in v1.6.6
func (n *ComparisonOperatorNode) Pos() int
func (ComparisonOperatorNode) String ¶
func (n ComparisonOperatorNode) String() string
type ConditionalNode ¶
type ConditionalNode struct { If Node Then Node Else Node // contains filtered or unexported fields }
A ConditionalNode represents an if-then-else expression.
func (*ConditionalNode) Pos ¶ added in v1.6.6
func (n *ConditionalNode) Pos() int
func (ConditionalNode) String ¶
func (n ConditionalNode) String() string
type DescendentNode ¶
type DescendentNode struct {
// contains filtered or unexported fields
}
A DescendentNode represents the descendent operator.
func (*DescendentNode) Pos ¶ added in v1.6.6
func (n *DescendentNode) Pos() int
func (DescendentNode) String ¶
func (DescendentNode) String() string
type ErrType ¶
type ErrType uint
ErrType describes the type of an error.
const ( ErrSyntaxError ErrType ErrUnexpectedEOF ErrUnexpectedToken ErrMissingToken ErrPrefix ErrInfix ErrUnterminatedString ErrUnterminatedRegex ErrUnterminatedName ErrIllegalEscape ErrIllegalEscapeHex ErrInvalidNumber ErrNumberRange ErrEmptyRegex ErrInvalidRegex ErrGroupPredicate ErrGroupGroup ErrPathLiteral ErrIllegalAssignment ErrIllegalParam ErrDuplicateParam ErrParamCount ErrInvalidUnionType ErrUnmatchedOption ErrUnmatchedSubtype ErrInvalidSubtype ErrInvalidParamType )
Error types returned by the parser.
type FunctionApplicationNode ¶
A FunctionApplicationNode represents a function application operation.
func (*FunctionApplicationNode) Pos ¶ added in v1.6.6
func (n *FunctionApplicationNode) Pos() int
func (FunctionApplicationNode) String ¶
func (n FunctionApplicationNode) String() string
type FunctionCallNode ¶
A FunctionCallNode represents a call to a function.
func (*FunctionCallNode) Pos ¶ added in v1.6.6
func (n *FunctionCallNode) Pos() int
func (FunctionCallNode) String ¶
func (n FunctionCallNode) String() string
type GroupNode ¶
type GroupNode struct { Expr Node *ObjectNode // contains filtered or unexported fields }
A GroupNode represents a group expression.
type LambdaNode ¶
A LambdaNode represents a user-defined JSONata function.
func (*LambdaNode) Pos ¶ added in v1.6.6
func (n *LambdaNode) Pos() int
func (LambdaNode) Shorthand ¶
func (n LambdaNode) Shorthand() bool
Shorthand returns true if the lambda function was defined with the shorthand symbol "λ", and false otherwise. This doesn't affect evaluation but may be useful when recreating a JSONata expression from its AST.
func (LambdaNode) String ¶
func (n LambdaNode) String() string
type NameNode ¶
type NameNode struct { Value string // contains filtered or unexported fields }
A NameNode represents a JSON field name.
type NegationNode ¶
type NegationNode struct { RHS Node // contains filtered or unexported fields }
A NegationNode represents a numeric negation operation.
func (*NegationNode) Pos ¶ added in v1.6.6
func (n *NegationNode) Pos() int
func (NegationNode) String ¶
func (n NegationNode) String() string
type NullNode ¶
type NullNode struct {
// contains filtered or unexported fields
}
A NullNode represents the JSON null value.
type NumberNode ¶
type NumberNode struct { Value float64 // contains filtered or unexported fields }
A NumberNode represents a number literal.
func (*NumberNode) Pos ¶ added in v1.6.6
func (n *NumberNode) Pos() int
func (NumberNode) String ¶
func (n NumberNode) String() string
type NumericOperator ¶
type NumericOperator uint8
A NumericOperator is a mathematical operation between two numeric values.
const ( NumericAdd NumericOperator NumericSubtract NumericMultiply NumericDivide NumericModulo )
Numeric operations supported by JSONata.
func (NumericOperator) String ¶
func (op NumericOperator) String() string
type NumericOperatorNode ¶
type NumericOperatorNode struct { Type NumericOperator LHS Node RHS Node // contains filtered or unexported fields }
A NumericOperatorNode represents a numeric operation.
func (*NumericOperatorNode) Pos ¶ added in v1.6.6
func (n *NumericOperatorNode) Pos() int
func (NumericOperatorNode) String ¶
func (n NumericOperatorNode) String() string
type ObjectNode ¶
type ObjectNode struct { Pairs [][2]Node // contains filtered or unexported fields }
An ObjectNode represents an object, an unordered list of key-value pairs.
func (*ObjectNode) Pos ¶ added in v1.6.6
func (n *ObjectNode) Pos() int
func (ObjectNode) String ¶
func (n ObjectNode) String() string
type ObjectTransformationNode ¶
type ObjectTransformationNode struct { Pattern Node Updates Node Deletes Node // contains filtered or unexported fields }
An ObjectTransformationNode represents the object transformation operator.
func (*ObjectTransformationNode) Pos ¶ added in v1.6.6
func (n *ObjectTransformationNode) Pos() int
func (ObjectTransformationNode) String ¶
func (n ObjectTransformationNode) String() string
type ParamOpt ¶
type ParamOpt uint8
A ParamOpt represents the options on a parameter in a lambda function signature.
const ( // ParamOptional denotes an optional parameter. ParamOptional ParamOpt // ParamVariadic denotes a variadic parameter. ParamVariadic // ParamContextable denotes a parameter that can be // replaced by the evaluation context if no value is // provided by the caller. ParamContextable )
type ParamType ¶
type ParamType uint
A ParamType represents the type of a parameter in a lambda function signature.
type PartialNode ¶
A PartialNode represents a partially applied function.
func (*PartialNode) Pos ¶ added in v1.6.6
func (n *PartialNode) Pos() int
func (PartialNode) String ¶
func (n PartialNode) String() string
type PathNode ¶
A PathNode represents a JSON object path. It consists of one or more 'steps' or Nodes (most commonly NameNode objects).
type PlaceholderNode ¶
type PlaceholderNode struct {
// contains filtered or unexported fields
}
A PlaceholderNode represents a placeholder argument in a partially applied function.
func (*PlaceholderNode) Pos ¶ added in v1.6.6
func (n *PlaceholderNode) Pos() int
func (PlaceholderNode) String ¶
func (PlaceholderNode) String() string
type PredicateNode ¶
A PredicateNode represents a predicate expression.
func (*PredicateNode) Pos ¶ added in v1.6.6
func (n *PredicateNode) Pos() int
func (PredicateNode) String ¶
func (n PredicateNode) String() string
type SortDir ¶
type SortDir uint8
SortDir describes the sort order of a sort operation.
const ( SortDefault SortDir SortAscending SortDescending )
Sort orders supported by JSONata.
type StringConcatenationNode ¶
A StringConcatenationNode represents a string concatenation operation.
func (*StringConcatenationNode) Pos ¶ added in v1.6.6
func (n *StringConcatenationNode) Pos() int
func (StringConcatenationNode) String ¶
func (n StringConcatenationNode) String() string
type StringNode ¶
type StringNode struct { Value string // contains filtered or unexported fields }
A StringNode represents a string literal.
func (*StringNode) Pos ¶ added in v1.6.6
func (n *StringNode) Pos() int
func (StringNode) String ¶
func (n StringNode) String() string
type TypedLambdaNode ¶
type TypedLambdaNode struct { *LambdaNode In []Param Out []Param // contains filtered or unexported fields }
A TypedLambdaNode represents a user-defined JSONata function with a type signature.
func (*TypedLambdaNode) Pos ¶ added in v1.6.6
func (n *TypedLambdaNode) Pos() int
func (TypedLambdaNode) String ¶
func (n TypedLambdaNode) String() string
type VariableNode ¶
type VariableNode struct { Name string // contains filtered or unexported fields }
A VariableNode represents a JSONata variable.
func (*VariableNode) Pos ¶ added in v1.6.6
func (n *VariableNode) Pos() int
func (VariableNode) String ¶
func (n VariableNode) String() string
type WildcardNode ¶
type WildcardNode struct {
// contains filtered or unexported fields
}
A WildcardNode represents the wildcard operator.
func (*WildcardNode) Pos ¶ added in v1.6.6
func (n *WildcardNode) Pos() int
func (WildcardNode) String ¶
func (WildcardNode) String() string