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 AssignmentNode ¶
An AssignmentNode represents a variable assignment.
func (AssignmentNode) String ¶
func (n AssignmentNode) String() string
type BooleanNode ¶
type BooleanNode struct {
Value bool
}
A BooleanNode represents the boolean constant true or false.
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 }
A BooleanOperatorNode represents a boolean operation.
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 }
A ComparisonOperatorNode represents a comparison operation.
func (ComparisonOperatorNode) String ¶
func (n ComparisonOperatorNode) String() string
type ConditionalNode ¶
A ConditionalNode represents an if-then-else expression.
func (ConditionalNode) String ¶
func (n ConditionalNode) String() string
type DescendentNode ¶
type DescendentNode struct{}
A DescendentNode represents the descendent operator.
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) String ¶
func (n FunctionApplicationNode) String() string
type FunctionCallNode ¶
A FunctionCallNode represents a call to a function.
func (FunctionCallNode) String ¶
func (n FunctionCallNode) String() string
type GroupNode ¶
type GroupNode struct { Expr Node *ObjectNode }
A GroupNode represents a group expression.
type LambdaNode ¶
A LambdaNode represents a user-defined JSONata function.
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
}
A NegationNode represents a numeric negation operation.
func (NegationNode) String ¶
func (n NegationNode) String() string
type Node ¶
type Node interface { String() string // contains filtered or unexported methods }
Node represents an individual node in a syntax tree.
type NumberNode ¶
type NumberNode struct {
Value float64
}
A NumberNode represents a number literal.
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 }
A NumericOperatorNode represents a numeric operation.
func (NumericOperatorNode) String ¶
func (n NumericOperatorNode) String() string
type ObjectNode ¶
type ObjectNode struct {
Pairs [][2]Node
}
An ObjectNode represents an object, an unordered list of key-value pairs.
func (ObjectNode) String ¶
func (n ObjectNode) String() string
type ObjectTransformationNode ¶
An ObjectTransformationNode represents the object transformation operator.
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) 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{}
A PlaceholderNode represents a placeholder argument in a partially applied function.
func (PlaceholderNode) String ¶
func (PlaceholderNode) String() string
type PredicateNode ¶
A PredicateNode represents a predicate expression.
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) String ¶
func (n StringConcatenationNode) String() string
type StringNode ¶
type StringNode struct {
Value string
}
A StringNode represents a string literal.
func (StringNode) String ¶
func (n StringNode) String() string
type TypedLambdaNode ¶
type TypedLambdaNode struct { *LambdaNode In []Param Out []Param }
A TypedLambdaNode represents a user-defined JSONata function with a type signature.
func (TypedLambdaNode) String ¶
func (n TypedLambdaNode) String() string
type VariableNode ¶
type VariableNode struct {
Name string
}
A VariableNode represents a JSONata variable.
func (VariableNode) String ¶
func (n VariableNode) String() string
type WildcardNode ¶
type WildcardNode struct{}
A WildcardNode represents the wildcard operator.
func (WildcardNode) String ¶
func (WildcardNode) String() string