4.5JSON path (API only)
Type: json.<path>, such as json.data.status. Checks: one value inside a JSON response. JSON is a common text format for data, such as {"status": "ok"}. It works on URL, API and multi-step API monitors. You add it through the API. The dashboard does not offer it, but keeps it when you edit the monitor.
Write the path as names joined by dots. To pick an item from a list, use its position, counting from 0. For example, json.items.0.sku is the sku of the first item. A path must not be empty: json. alone is refused.
How obsrvly reads the value at the path:
- Text is read as it is.
- Numbers are read as numbers.
1.0compares as1, and1e3as1000. - Yes/no values read as
trueorfalse. null(no value) reads as empty text.- An object or a list reads as compact JSON text. Use
containswith it.
Operators: eq, neq, contains, matches. Use gt and lt for numbers.
| Type | Operator | Value | What it means |
|---|---|---|---|
json.status | eq | ok | The top-level status is ok. |
json.data.count | gt | 0 | The result is not empty. |
json.items.0.stock | gt | 0 | The first item is in stock. |
{"type": "json.status", "op": "ASSERTION_OP_EQ",
"value": "ok"}When it fails: assertion json.status == "ok": got "degraded". If the path does not exist, or the response is not JSON, you see assertion json.status: path not found. obsrvly reads the first 1 MiB of the body.