Online JSONPath tester tool allows you to test and debug your JSONPath expressions against an JSON string or file.
You can see JSONPath syntax to help you to find your JSONPath query.
You can see the user guide to help you to use this JSONPath tester.
In order to test your JSONPath expression, you must:
To fill "Your JSON structure" editor, you can:
It use JSONPath Plus library.
XPath (XML Path Language) is a query language for selecting nodes from a XML data.
JSONPath is XPath for JSON: JSONPath is a query language for JSON.
Developers can use JSONPath in a variety of programming languages (Javascript, PHP, Java, ...).
JSONPath | Description |
---|---|
$ | The root object / element |
@ | The current object / element |
. | Child member operator |
.. | Recursive descendant operator; JSONPath borrows this syntax from E4X |
* | Wildcard matching all objects/elements regardless their names |
[] | Subscript operator |
[,] | Union operator for alternate names or array indices as a set |
[start:end:step] | Array slice operator borrowed from ES4 / Python |
?() | Applies a filter (script) expression via static evaluation |
() | Script expression via static evaluation |
{ "house": { "room": [ { "name": "Bedroom", "area": 10 }, { "name": "Bathroom", "area": 9 }, { "name": "Kitchen", "appliance": "microwave", "area": 12 } ], "garden": { "area": 150 } } }
The following are some examples of JSONPath expressions:
JSONPath | Description |
---|---|
$.house.* | All things in house, which are some rooms and a garden |
$..name | All names |
$..room[2] | The third room |
$..room[(@.length-1)] | The last room |
$..room[-1:] | The last room |
$..room[0,1] | The first two rooms |
$..room[:2] | The first two rooms |
$..room[?(@.appliance)] | Filter all rooms with home appliance |
$..room[?(@.area<10)] | Filter all rooms smaller than 10 |
$..room[?(@.area<10 && @.name=="Bedroom")] | Filter all Bedrooms smaller than 10 |
$.house.room[*].area | The area of all rooms in the house |
Comments
DANIEL MARQUES PEREIRA-2021-01-19 14:07
Cyril-2021-01-19 14:30
asd-2022-02-05 18:13
Lienix-2022-02-22 12:09
E.g. instead of this
$.house.room[?(@.name == 'Bedroom')]
use an 'in' expression to geht two results:
$.house.room[?(@.name in ['Bedroom', 'Bathroom'])]
But that isn' t working! What is the trick to make it correct?
Lucas-2022-03-23 08:37