X/JSON Path Tester

Table of contents


Description

The tool is designed to validate data in XPath / JSONPath format and help in writing correct expressions for parsing data from XML and JSON documents.

How to open a window?

On the toolbar, if this button is enabled in the appearance settings:

Or Main Menu - Tools - X/JSON Path Constructor:

How to check if XPath/JSONPath expression is correct?

  1. Insert the code for processing into the input field;

  2. Insert the ready XPath/JSONPath expression that needs to be checked;

  3. Press the "Test" button;

  4. In the "Processing Result" field, we get the matches obtained for the given expression, if it was composed correctly.

How to quickly compose an XPath/JSONPath expression?

  1. Insert the code for processing into the input field;

  2. Press the button "Find";

  3. In the “XPath / JSONPath” field we get an expression, a ready-made expression;

  4. In the "Processing Result" field, we get the matches obtained for the given expression, if it was composed correctly.

The resulting expression can be used in the Process JSON and XML action.

The Beautify button allows you to automatically format the code and bring it to an easy-to-read format.


Basic XPath syntax.

Expression

Result

Expression

Result

hostname

Selects all nodes named "node_name"

/

Selects from root node

//

Selects nodes from the current node matching the selection, regardless of their location

.

Selects the current node

..

Selects the parent of the current node

@

Selects attributes

Special characters are used to search for unknown nodes:

Special character

Description

Special character

Description

*

Matches any element node

@*

Matches any attribute node

node()

Matches any node of any type


Basic JSONPath syntax.

Expression

Result

Expression

Result

$

Selects from root node

..

Parent operator

... or []

Descendant operator

..

Selects nodes from the current node matching the selection

@

Selects the current node

?()

Applies a filter expression

Examples:

{ "store": { "book": [ { "category": "reference", "author": "Nigel Rees", "title": "Sayings of the Century", "price": 8.95 }, { "category": "fiction", "author": "Evelyn Waugh", "title": "Sword of Honour", "price": 12.99 }, { "category": "fiction", "author": "Herman Melville", "title": "Moby Dick", "isbn": "0-553-21311-3", "price": 8.99 }, { "category": "fiction", "author": "J. R. R. Tolkien", "title": "The Lord of the Rings", "isbn": "0-395-19395-8", "price": 22.99 } ], "bicycle": { "color": "red", "price": 19.95 } } }

XPath

JSONPath

Result

/store/book/author

$.store.book[*].author

“author” elements of all “book” elements in “store”

//author

$..author

all “author” elements

/store/*

$.store.*

all content in "store"

/store//price

$.store..price

the value of the price of the "price" element of all elements in the "store"

//book[3]

$..book[2]

third element "book"

//book[last()]

$..book[(@.length-1)]
$..book[-1:]

the last element "book"

//book[position()<3]

$..book[0,1]
$..book[:2]

the first 2 elements of "book"

//book[isbn]

$..book[?(@.isbn)]

filter all elements of “book” with value “isbn”

//book[price<10]

$..book[?(@.price<10)]

filter all “book” elements with “price” value less than 10

//*

$..*

all elements in the XML document. All members of the JSON structure.