Skip to main content
Version: 4.12.1

Using jsonpath expression language in Dovetail

Jsonpath expression is supported by the following components:

Selecting nodes

General

JSON stands for JavaScript Object Notation. It's a lightweight data format to exchange data. JSONPath is a query language for JSON, similar to XPath for XML.

You can test your JSONPath with this Online tester.

ExpressionDescription
$Select from the root node.
@Selects from the current node
*) expresses all elements within the specified scope. For instance, book[] indicates all nodes inside a book array.
.Selects the child node
[]Selects the child node by name or index
:The : operator is the array slice operator, so you can slice collections using the syntax [start:end:step] to return a subcollection of a collection.

Examples

This json is used in the examples below.

{ "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
}
}
}

Function examples

XPathJSONPathResult
/store/book/author$.store.book[*].authorthe authors of all books in the store
//author$..authorall authors
/store/*$.store.*all things in store, which are some books and a red bicycle.
/store//price$.store..pricethe price of everything in the store.
//book[3]$..book[2]the third book
//book[last()]$..book[(@.length-1)] $..book[-1:]the last book in order.
//book[position()<3]$..book[0,1] $..book[:2]the first two books
//book[isbn]$..book[?(@.isbn)]filter all books with isbn number
//book[price<10]$..book[?(@.price<10)]filter all books cheapier than 10
//*$..*all Elements in XML document. All members of JSON structure.

Useful references

For more detailed information go to: