filter

package
v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package filter provides JQ filtering for response bodies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyJQ

func ApplyJQ(input string, filterExpr string) (string, error)

ApplyJQ applies a jq filter expression to the given JSON input string. Returns the filtered result as a string. If the filter produces multiple values, they are joined with newlines.

func ApplyJQWithVars added in v0.5.0

func ApplyJQWithVars(input string, filterExpr string, variables map[string]any) (string, error)

ApplyJQWithVars applies a jq filter expression with optional variables. Variables is a map of variable names to values (e.g., map[string]any{"_headers": {...}}).

Types

type AssertionDetail added in v0.5.0

type AssertionDetail struct {
	Expression    string // The full assertion expression
	LeftSide      string // The left side of comparison (e.g., ".id")
	Operator      string // The operator (e.g., "==", "!=", ">", etc.)
	RightSide     string // The right side/expected value (e.g., "999")
	ActualValue   string // The actual value from the left side evaluation
	ExpectedValue string // The expected value (right side)
}

AssertionDetail contains detailed information about an assertion failure

func EvalJQBoolWithDetail added in v0.5.0

func EvalJQBoolWithDetail(input string, expr string) (bool, *AssertionDetail, error)

EvalJQBoolWithDetail evaluates a JQ expression and returns detailed information about the assertion. This is useful for generating helpful error messages when assertions fail.

func EvalJQBoolWithDetailAndVars added in v0.5.0

func EvalJQBoolWithDetailAndVars(input string, expr string, variables map[string]any) (bool, *AssertionDetail, error)

EvalJQBoolWithDetailAndVars evaluates a JQ expression with optional variables. Variables is a map of variable names to values (e.g., map[string]any{"_headers": {...}}).

Jump to

Keyboard shortcuts

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