query

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 5 Imported by: 0

Documentation

Overview

Package query provides JQ-based querying for HTTP response bodies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine struct{}

Engine executes JQ queries against JSON data.

func NewEngine

func NewEngine() *Engine

NewEngine creates a new query engine.

func (*Engine) Query

func (e *Engine) Query(data []byte, expression string, deduplicate bool, maxResults int) (*QueryResult, error)

Query executes a JQ expression against JSON data. Returns the extracted values and any errors encountered.

func (*Engine) QueryMultiple

func (e *Engine) QueryMultiple(dataList [][]byte, expression string, deduplicate bool, maxResults int) (*QueryResult, error)

QueryMultiple executes a JQ expression against multiple JSON data inputs. Combines results from all inputs, optionally deduplicating across all. Optional labels can be provided to identify each data input in error messages.

func (*Engine) QueryMultipleWithLabels

func (e *Engine) QueryMultipleWithLabels(dataList [][]byte, labels []string, expression string, deduplicate bool, maxResults int) (*QueryResult, error)

QueryMultipleWithLabels executes a JQ expression against multiple JSON data inputs. Labels identify each input for better error messages (e.g., entry IDs).

func (*Engine) ValidateExpression

func (e *Engine) ValidateExpression(expression string) error

ValidateExpression checks if a JQ expression is valid without executing it.

type QueryResult

type QueryResult struct {
	Values         []any          `json:"values"`                    // Extracted values
	Errors         []string       `json:"errors,omitempty"`          // Per-item errors (e.g., type mismatch)
	RawCount       int            `json:"raw_count"`                 // Count before deduplication
	MatchedIndices []int          `json:"matched_indices,omitempty"` // Indices of inputs that produced values
	LabelCounts    map[string]int `json:"label_counts,omitempty"`    // Value count per label
}

QueryResult contains the results of a JQ query.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL