Basic selection
Select elements by using a forward slash (/). Select array items by using square brackets ( [ ] ).
The following table shows examples of basic selection of JSON elements.
Example | Description | State | Expression | Result |
---|---|---|---|---|
Primitive | Selects a JSON primitive. | { "object": { "attr1": "value1", "attr2": "value2" }
} |
/object/attr1 |
"value1" |
New in V2 String Index | Selects a character of a string. | { "object": { "attr1": "value1", "attr2": "value2" }
} |
/object/attr1[0] |
"v" |
Object | Selects a JSON object. | { "object": { "attr1": "value1", "attr2": "value2" }
} |
/object |
{ "attr1": "value1", "attr2": "value2" } |
Array | Selects a JSON array. | { "array": [ "value1", "value2" ] } |
/array |
[ "value1", "value2" ] |
Array Index | Selects an item of a JSON array by index. The index starts at 0. | { "array": [ 1.1, 2.2 ] } |
/array[1] |
2.2 |
Nested | Selects an attribute of an object that is nested in an array. | { "array": [ { "id": 123 }, { "id": 456
} ] } |
/array[1]/id |
456 |
Multiple Nested | Selects all attributes of an object that is nested in an array. | { "array": [ { "id": 123 }, { "id": 456
} ] } |
/array/id |
[ 123, 456 ] |
Single Quoted Keys | Selects key names by using single quotation marks. | { "name with spaces": { "some attribute": true, "another attribute":
false } } |
/'name with spaces'/'some attribute' |
true |
Double Quoted Keys | Selects key names by using double quotation marks. | { "name with spaces": { "some attribute": true, "another attribute":
false } } |
/"name with spaces"/"some attribute" |
true |
Unicode Support | Selects by using Unicode keys and values. | { "a͓̽t͓̽t͓̽r͓̽": "v͓̽a͓̽l͓̽u͓̽e͓̽" } |
/"a͓̽t͓̽t͓̽r͓̽" |
"v͓̽a͓̽l͓̽u͓̽e͓̽" |