Documentation
¶
Overview ¶
Package query provides JQ-based querying for HTTP response bodies.
Index ¶
- type Engine
- func (e *Engine) Query(data []byte, expression string, deduplicate bool, maxResults int) (*QueryResult, error)
- func (e *Engine) QueryMultiple(dataList [][]byte, expression string, deduplicate bool, maxResults int) (*QueryResult, error)
- func (e *Engine) QueryMultipleWithLabels(dataList [][]byte, labels []string, expression string, deduplicate bool, ...) (*QueryResult, error)
- func (e *Engine) ValidateExpression(expression string) error
- type QueryResult
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 (*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 ¶
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.