Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.ellomas.com/llms.txt

Use this file to discover all available pages before exploring further.

Working with JSON

JSONPath is the query language used across Replay for extracting values from responses and targeting assertion paths.

JSONPath Basics

JSONPath expressions navigate JSON structures:
extract:
  user_id: $.data.id
ExpressionDescription
$Root object
.fieldDot-notation child access
[n]Array index
[*]Array wildcard (all elements)
..Deep scan (recursive descent)
[start:end]Array slice

Shorthand Syntax

Replay accepts several shorthand forms:
# Full JSONPath
extract:
  token: $.data.token

# Without leading $
extract:
  token: data.token

# With res. prefix (matches HTTP response structure)
extract:
  status_code: res.status

Common Patterns

Nested Fields

extract:
  city: $.user.address.city
  org_name: $.data.organization.name

Array Access

extract:
  first_item: $.data.items[0]
  third_item: $.data.items[2]
  last_item: $.data.items[-1]

Array Wildcards

extract:
  all_names: $.data.users[*].name
  all_prices: $..price

Array Slices

extract:
  first_two: $.data.items[0:2]
  from_third: $.data.items[2:]

In HTTP Steps

The HTTP response is structured as:
{
  "status": 200,
  "data": { ... },
  "header": { ... }
}
Target each part:
extract:
  status_code: res.status               # HTTP status code
  response_body: $.data                 # Parsed JSON body
  content_type: res.header.Content-Type[0]  # Response header

In Database Steps

PostgreSQL results are arrays of row objects:
[
  { "id": 1, "name": "Alice" },
  { "id": 2, "name": "Bob" }
]
extract:
  first_name: $[0].name
  all_ids: $[*].id

In Shell Steps

Shell stdout is parsed as JSON if possible:
- name: generate
  type: shell
  command: 'echo "{\"result\": {\"id\": 42, \"status\": \"ok\"}}"'
  extract:
    item_id: $.result.id
If the output is not valid JSON, use $ to grab the raw string:
extract:
  raw_output: $

Assertions with JSONPath

assert:
  - ["$.status", "eq", 200]
  - ["$.data.email", "contains", "@"]
  - ["$.data.items", "not_null"]
  - ["$.data.count", "gt", 0]
  - ["$[0].name", "eq", "Alice"]

Debugging JSONPath

Enable debug mode to see the full response structure:
config:
  http:
    debug: true
This prints the request and response to the terminal, making it easy to find the right path.

What’s Next?