failover.io
  1. Home
  2. Free tools
  3. JSONPath tester

JSONPath tester

Paste a JSON response and a JSONPath expression to see every match. It also tells you if the path works in a failover.io API monitor.

Matches
Type

Result


JSONPath syntax

ExpressionWhat it selects
$The whole document
$.result.healthyA key inside a key
$['result']['block_height']The same with brackets, needed for keys with spaces or dots
$.result.peers[0]The first item of an array
$.result.peers[-1:]The last item
$.result.peers[*].idA key in every item
$..latency_msA key at any depth
$.result.peers[?(@.latency_ms > 20)]Items that match a condition

The tester runs JSONPath Plus in your browser. Nothing you paste is sent anywhere.

JSONPath examples

  • Is the service healthy? $.result.healthy returns true or false.
  • Every peer id: $.result.peers[*].id returns ["node-a", "node-b"].
  • Slow peers only: $.result.peers[?(@.latency_ms > 20)].id returns ["node-b"].
  • All latencies wherever they are: $..latency_ms returns [12, 48].

Use the path in an API monitor

A 200 status only means the server answered. Plenty of broken APIs return 200 with "healthy": false or a block height that stopped moving. failover.io HTTP monitors read the JSON body and check a value: it exists, equals, doesn't equal, contains or is greater or less than a number. If the check fails, the monitor is down even with a 200.

Monitors take simple paths: keys separated by dots and array indexes in brackets, written without the leading $.. So $.result.peers[0].id becomes result.peers[0].id. Wildcards, .. and filters select several values, so they don't work in a monitor. Under every result, the tester says whether your path works in a monitor and how to write it.

For blockchain nodes, the path you want is usually the block height or slot number. See how to monitor a JSON-RPC or blockchain node.

Frequently asked questions

What is JSONPath?

A way to select values from a JSON document, the way XPath does for XML. An expression starts with $ for the root, then names keys and array indexes, like $.store.book[0].title.

How do I test a JSONPath expression?

Paste the JSON and the expression into the tester above. It shows every match and its type as you type, in your browser.

What is the difference between $.key and $..key?

One dot selects the key directly under the current level. Two dots search every level, so $..id returns every id anywhere in the document.

Can I use JSONPath in a failover.io monitor?

Monitors use the simple form: keys and [n] indexes without the leading $., like result.peers[0].id. The tester converts it for you when it can.