Documentation ¶
Index ¶
- type Query
- type Tool
- func (t *Tool) Compile(source string, variables ...string) (result *Query, err error)
- func (t *Tool) Evaluate(source string, input, output any, variables ...Variable) error
- func (t *Tool) EvaluateBytes(source string, input []byte, output any, variables ...Variable) error
- func (t *Tool) EvaluateString(source, input string, output any, variables ...Variable) error
- type ToolBuilder
- type Variable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query contains the data and logic needed to evaluate a query. Instances are created using the Compile or Evaluate methods of the Tool type.
type Tool ¶
type Tool struct {
// contains filtered or unexported fields
}
Tool knows how to run JQ queries. Don't create instances of this directly, use the NewTool function instead.
func (*Tool) Compile ¶
Compile compiles the given query and saves it in a cache, so that evaluating the same query with the same variables later will not require compile it again.
func (*Tool) Evaluate ¶
Evaluate compiles the query and then evaluates it. The input can be any kind of object that can be serialized to JSON.
func (*Tool) EvaluateBytes ¶
EvaluateBytes compiles the query and then evaluates it. The input should be an array of bytes containing a JSON document.
type ToolBuilder ¶
type ToolBuilder struct {
// contains filtered or unexported fields
}
ToolBuilder contains the data needed to build a tool that knows how to run JQ queries. Don't create instances of this directly, use the NewTool function instead.
func NewTool ¶
func NewTool() *ToolBuilder
NewTool creates a builder that can then be used to create a JQ tool.
func (*ToolBuilder) Build ¶
func (b *ToolBuilder) Build() (result *Tool, err error)
Build uses the information stored in the builder to create a new JQ tool.
func (*ToolBuilder) SetCompilerOption ¶
func (b *ToolBuilder) SetCompilerOption(value *gojq.CompilerOption) *ToolBuilder
SetCompilerOption sets the CompileOption to pass to gojq.Compile. This is optional.
func (*ToolBuilder) SetLogger ¶
func (b *ToolBuilder) SetLogger(value *slog.Logger) *ToolBuilder
SetLogger sets the logger that the JQ tool will use to write the log. This is mandatory.