Documentation ¶
Index ¶
- Constants
- func FetchCache() error
- func FindAnyCase[T types.JsonType](o *types.JsonObject, key ...string) (*T, error)
- func LibraryInit(level zapcore.Level, safeMode bool)
- func ParseLambda(text string) ([]string, []string, error)
- func Process(name, input string, globalScope *types.JsonObject, ...) (utils.NavigableMap[string, *types.JsonObject], error)
- func ProcessAssertionsFile(name, input string, globalScope *types.JsonObject, timeout int64) error
- func ProcessLangFile(input string, scope *types.JsonObject) (string, error)
- func ProcessMCFunction(input string, scope *types.JsonObject) (string, error)
- func ProcessString(input string, scope *types.JsonObject, startToken, endToken string) (string, error)
- func PutValue(result *types.JsonObject, key string, r types.JsonType, path string) error
- func UnescapeString(text string) string
- func UnescapeStringToBuffer(text []rune, sb *strings.Builder, i *int, end rune) (bool, string)
- func VerifyReservedNames(o *types.JsonObject, path string) error
- type CollectingErrorListener
- type ExpressionVisitor
- func (v *ExpressionVisitor) ResolveScope(name string) types.JsonType
- func (v *ExpressionVisitor) Visit(tree antlr.ParseTree) (types.JsonType, error)
- func (v *ExpressionVisitor) VisitArray(context *parser.ArrayContext) (types.JsonType, error)
- func (v *ExpressionVisitor) VisitExpression(ctx *parser.ExpressionContext) (types.JsonType, error)
- func (v *ExpressionVisitor) VisitField(context *parser.FieldContext) (types.JsonType, error)
- func (v *ExpressionVisitor) VisitFunction_param(ctx *parser.Function_paramContext) (types.JsonType, error)
- func (v *ExpressionVisitor) VisitIndex(context *parser.IndexContext) (types.JsonType, error)
- func (v *ExpressionVisitor) VisitLambda(ctx *parser.LambdaContext) (types.JsonType, error)
- func (v *ExpressionVisitor) VisitName(context *parser.NameContext) (types.JsonType, error)
- func (v *ExpressionVisitor) VisitObject(context *parser.ObjectContext) (types.JsonType, error)
- func (v *ExpressionVisitor) VisitObject_field(context *parser.Object_fieldContext) (types.JsonType, error)
- func (v *ExpressionVisitor) VisitScript(ctx *parser.ScriptContext) (types.JsonType, error)
- func (v *ExpressionVisitor) VisitStatement(ctx *parser.StatementContext) (types.JsonType, error)
- func (v *ExpressionVisitor) VisitStatements(ctx *parser.StatementsContext) (types.JsonType, error)
- type JsonModule
- type LambdaVisitor
- func (v *LambdaVisitor) Visit(tree antlr.ParseTree)
- func (v *LambdaVisitor) VisitArray(context *parser.ArrayContext)
- func (v *LambdaVisitor) VisitExpression(ctx *parser.ExpressionContext)
- func (v *LambdaVisitor) VisitField(context *parser.FieldContext)
- func (v *LambdaVisitor) VisitFunction_param(ctx *parser.Function_paramContext)
- func (v *LambdaVisitor) VisitIndex(context *parser.IndexContext)
- func (v *LambdaVisitor) VisitLambda(ctx *parser.LambdaContext)
- func (v *LambdaVisitor) VisitObject(context *parser.ObjectContext)
- func (v *LambdaVisitor) VisitObject_field(context *parser.Object_fieldContext)
- type Result
- func Eval(text string, scope deque.Deque[*types.JsonObject], path string) (Result, error)
- func EvalScript(text string, scope deque.Deque[*types.JsonObject], path string) (Result, error)
- func EvalWithTempScope(text string, scope deque.Deque[*types.JsonObject], path string, ...) (Result, error)
- func QuickEval(text string, path string) (Result, error)
- type TemplateMatch
- type TemplateVisitor
Constants ¶
const DefaultIndexName = "index"
const DefaultName = "value"
const MaxInt64 = int64(^uint64(0) >> 1)
const WrongTypeErrTag = "wrong_type"
Variables ¶
This section is empty.
Functions ¶
func FindAnyCase ¶
FindAnyCase returns the first key that matches the given key, ignoring case.
func LibraryInit ¶
LibraryInit initializes jsonte in library mode level is the logging level safeMode is whether to run in safe mode, which disables unsafe functions
func Process ¶
func Process(name, input string, globalScope *types.JsonObject, modules map[string]JsonModule, timeout int64) (utils.NavigableMap[string, *types.JsonObject], error)
Process processes a template and returns a map of the processed templates
func ProcessAssertionsFile ¶
func ProcessAssertionsFile(name, input string, globalScope *types.JsonObject, timeout int64) error
func ProcessLangFile ¶
func ProcessLangFile(input string, scope *types.JsonObject) (string, error)
ProcessLangFile processes a lang file replacing all the jsonte expressions with their values
func ProcessMCFunction ¶
func ProcessMCFunction(input string, scope *types.JsonObject) (string, error)
ProcessMCFunction processes a file replacing all the jsonte expressions with their values
func ProcessString ¶
func ProcessString(input string, scope *types.JsonObject, startToken, endToken string) (string, error)
ProcessString processes a string replacing all the jsonte expressions with their values
func UnescapeString ¶
func UnescapeStringToBuffer ¶
UnescapeStringToBuffer unescapes a string to a buffer. If end is not 0, the unescaping will stop when the end rune is found. Returns true if the end rune is found and false otherwise. Also returns the escaped string for debugging purposes.
func VerifyReservedNames ¶
func VerifyReservedNames(o *types.JsonObject, path string) error
Types ¶
type CollectingErrorListener ¶
type CollectingErrorListener struct { *antlr.DefaultErrorListener Error error }
CollectingErrorListener is an error listener that collects all errors by appending them to the Error field
func (*CollectingErrorListener) SyntaxError ¶
func (l *CollectingErrorListener) SyntaxError(recognizer antlr.Recognizer, offendingSymbol interface{}, line, column int, msg string, e antlr.RecognitionException)
type ExpressionVisitor ¶
type ExpressionVisitor struct { parser.BaseJsonTemplateVisitor // contains filtered or unexported fields }
func (*ExpressionVisitor) ResolveScope ¶
func (v *ExpressionVisitor) ResolveScope(name string) types.JsonType
ResolveScope resolves a value from the scope by name
func (*ExpressionVisitor) Visit ¶
func (v *ExpressionVisitor) Visit(tree antlr.ParseTree) (types.JsonType, error)
func (*ExpressionVisitor) VisitArray ¶
func (v *ExpressionVisitor) VisitArray(context *parser.ArrayContext) (types.JsonType, error)
func (*ExpressionVisitor) VisitExpression ¶
func (v *ExpressionVisitor) VisitExpression(ctx *parser.ExpressionContext) (types.JsonType, error)
func (*ExpressionVisitor) VisitField ¶
func (v *ExpressionVisitor) VisitField(context *parser.FieldContext) (types.JsonType, error)
func (*ExpressionVisitor) VisitFunction_param ¶
func (v *ExpressionVisitor) VisitFunction_param(ctx *parser.Function_paramContext) (types.JsonType, error)
func (*ExpressionVisitor) VisitIndex ¶
func (v *ExpressionVisitor) VisitIndex(context *parser.IndexContext) (types.JsonType, error)
func (*ExpressionVisitor) VisitLambda ¶
func (v *ExpressionVisitor) VisitLambda(ctx *parser.LambdaContext) (types.JsonType, error)
func (*ExpressionVisitor) VisitName ¶
func (v *ExpressionVisitor) VisitName(context *parser.NameContext) (types.JsonType, error)
func (*ExpressionVisitor) VisitObject ¶
func (v *ExpressionVisitor) VisitObject(context *parser.ObjectContext) (types.JsonType, error)
func (*ExpressionVisitor) VisitObject_field ¶
func (v *ExpressionVisitor) VisitObject_field(context *parser.Object_fieldContext) (types.JsonType, error)
func (*ExpressionVisitor) VisitScript ¶
func (v *ExpressionVisitor) VisitScript(ctx *parser.ScriptContext) (types.JsonType, error)
func (*ExpressionVisitor) VisitStatement ¶
func (v *ExpressionVisitor) VisitStatement(ctx *parser.StatementContext) (types.JsonType, error)
func (*ExpressionVisitor) VisitStatements ¶
func (v *ExpressionVisitor) VisitStatements(ctx *parser.StatementsContext) (types.JsonType, error)
type JsonModule ¶
type JsonModule struct { Name *types.JsonString Scope *types.JsonObject Template *types.JsonObject Copy *types.JsonString }
JsonModule represents a module that can be extended by a template
func LoadModule ¶
func LoadModule(input string, globalScope *types.JsonObject, timeout int64) (JsonModule, error)
LoadModule loads a module from a file and returns a JsonModule
type LambdaVisitor ¶
type LambdaVisitor struct { parser.BaseJsonTemplateVisitor // contains filtered or unexported fields }
func (*LambdaVisitor) Visit ¶
func (v *LambdaVisitor) Visit(tree antlr.ParseTree)
func (*LambdaVisitor) VisitArray ¶
func (v *LambdaVisitor) VisitArray(context *parser.ArrayContext)
func (*LambdaVisitor) VisitExpression ¶
func (v *LambdaVisitor) VisitExpression(ctx *parser.ExpressionContext)
func (*LambdaVisitor) VisitField ¶
func (v *LambdaVisitor) VisitField(context *parser.FieldContext)
func (*LambdaVisitor) VisitFunction_param ¶
func (v *LambdaVisitor) VisitFunction_param(ctx *parser.Function_paramContext)
func (*LambdaVisitor) VisitIndex ¶
func (v *LambdaVisitor) VisitIndex(context *parser.IndexContext)
func (*LambdaVisitor) VisitLambda ¶
func (v *LambdaVisitor) VisitLambda(ctx *parser.LambdaContext)
func (*LambdaVisitor) VisitObject ¶
func (v *LambdaVisitor) VisitObject(context *parser.ObjectContext)
func (*LambdaVisitor) VisitObject_field ¶
func (v *LambdaVisitor) VisitObject_field(context *parser.Object_fieldContext)
type Result ¶
type Result struct { Value types.JsonType Action types.JsonAction Name string IndexName string Scope deque.Deque[*types.JsonObject] VariableScope *types.JsonObject }
Result is the result of evaluating an expression
func EvalScript ¶
EvalScript evaluates the given script and returns the result
func EvalWithTempScope ¶
func EvalWithTempScope(text string, scope deque.Deque[*types.JsonObject], path string, temp ...*types.JsonObject) (Result, error)
EvalWithTempScope evaluates the given expression and returns the result
type TemplateMatch ¶
func FindTemplateMatches ¶
func FindTemplateMatches(input, startToken, endToken string) ([]TemplateMatch, error)
FindTemplateMatches processes a string replacing all the jsonte expressions with their values
type TemplateVisitor ¶
type TemplateVisitor struct {
// contains filtered or unexported fields
}