Skip to main content

JSON Selection

Use JSON selectors anywhere Hen expects a response-body operand, including captures, assertions, redaction rules, and dependency reads.

Common Selectors

& body.user.id -> $USER_ID
^ & body.items[0].name == "first"
^ & body.[0].id == 123
^ & body.jobs[? (recipient == $RECIPIENT || recipient == "fallback@example.com") && status != "failed"].status == "succeeded"
^ & json(body.result.content[0].text).items[0].id == "123"
^ &[Create Job].body.result.state == "completed"

Selector Rules

  • body starts from the current response JSON value.
  • Use dot access for object fields such as body.user.id.
  • Use [index] for arrays nested under an object key, such as body.items[0].name.
  • Use body.[index] when the root value is an array.
  • Use [? ...] to query an array and continue from the matching element.

Filter Queries

Filter queries:

  • evaluate paths relative to each array item
  • support == and !=
  • accept scalar literals or $VARIABLE values
  • may combine clauses with &&, ||, and parentheses
  • must resolve to exactly one element

Zero or multiple matches are failures.

Decoded JSON

Use json(...) when a selected value contains stringified JSON and you want another traversal pass.

Use &[Request Name].body... when selecting from a declared dependency response instead of the current response.

Hen intentionally stays narrower than full JSONPath or jq. There are no wildcards, slices, projections, recursive descent, nested filters, regex filters, or structural filter RHS values.