This document describes the JSONPath syntax used in the application for querying JSON data.
JSONPath expressions always start with $, which represents the root object.
$ - Root object.property - Child property access['property'] - Child property access (bracket notation)[index] - Array index access[*] - All elements in an array..property - Recursive descent (all properties with this name)[start:end:step] - Array slice[?(@.property)] - Filter expression (elements with the specified property)[?(@.property == value)] - Filter with comparison[?(@.property > value)] - Filter with comparison[?(@.property in [val1, val2])] - Filter with value matching$.store.book[0].title # First book's title $.store.book[*].title # All book titles $.store.book[*].price # All book prices
$[0] # First element $[*] # All elements $[0,1,2] # First three elements $[0:2] # Range of elements (first two)
$.store.book[?(@.price < 10)] # Books cheaper than $10 $.store.book[?(@.category == 'fiction')] # Fiction books $.store.book[?(@.authors[*] == 'J. R. R. Tolkien')] # Books by Tolkien
$..book # All books anywhere in the document $..title # All titles anywhere in the document $root:$.property # Reference to root from a nested context
In this application, JSONPath is used for:
Example selectors from the project:
$.val1 # Simple property access $.nested_1.nested_1_1 # Nested property access $['split1'] # Bracket notation $[*].table # All tables in an array $.additionalData2[?(@.name == 'N1')].values[*].val # Filtered nested access
Reference: - JSONPath - XPath for JSON (https://goessner.net/articles/JsonPath/) - JSONPath Online Evaluator (https://jsonpath.com/)