-
-
Notifications
You must be signed in to change notification settings - Fork 27
Queries
Below, you will find a list of queries, which are currently supported by this library. This list has been created, based on the great comparison list project by Christoph Burgmer.
Other queries might be supported too, but there's no consensus (aka expected result), therefore it is unclear if the results returned are correct, or not.
Corresponding unit/functional tests for these specific queries can be found here.
Array Slice
# Array Slice
Test Data:
[
"first",
"second",
"third",
"forth",
"fifth"
]
Selector:
$[1:3]
Consensus:
[
"second",
"third"
]
Test Data:
[
"first",
"second",
"third",
"forth",
"fifth"
]
Selector:
$[0:5]
Consensus:
[
"first",
"second",
"third",
"forth",
"fifth"
]
Test Data:
[
"first",
"second",
"third"
]
Selector:
$[7:10]
Consensus:
[]
Test Data:
{
":": 42,
"more": "string",
"a": 1,
"b": 2,
"c": 3,
"1:3": "nice"
}
Selector:
$[1:3]
Consensus:
[]
Test Data:
[
"first",
"second",
"third"
]
Selector:
$[1:10]
Consensus:
[
"second",
"third"
]
Test Data:
[
2,
"a",
4,
5,
100,
"nice"
]
Selector:
$[-4:-5]
Consensus:
[]
Test Data:
[
2,
"a",
4,
5,
100,
"nice"
]
Selector:
$[-4:-4]
Consensus:
[]
Test Data:
[
2,
"a",
4,
5,
100,
"nice"
]
Selector:
$[-4:-3]
Consensus:
[
4
]
Test Data:
[
2,
"a",
4,
5,
100,
"nice"
]
Selector:
$[-4:1]
Consensus:
[]
Test Data:
[
2,
"a",
4,
5,
100,
"nice"
]
Selector:
$[-4:2]
Consensus:
[]
Test Data:
[
2,
"a",
4,
5,
100,
"nice"
]
Selector:
$[-4:3]
Consensus:
[
4
]
Test Data:
[
"first",
"second",
"third",
"forth",
"fifth"
]
Selector:
$[1:]
Consensus:
[
"second",
"third",
"forth",
"fifth"
]
Test Data:
[
"first",
"second",
"third",
"forth",
"fifth"
]
Selector:
$[:2]
Consensus:
[
"first",
"second"
]
Test Data:
[
"first",
"second"
]
Selector:
$[:]
Consensus:
[
"first",
"second"
]
Test Data:
[
"first",
"second"
]
Selector:
$[::]
Consensus:
[
"first",
"second"
]
Test Data:
[
2,
"a",
4,
5,
100,
"nice"
]
Selector:
$[3:-4]
Consensus:
[]
Test Data:
[
2,
"a",
4,
5,
100,
"nice"
]
Selector:
$[3:-3]
Consensus:
[]
Test Data:
[
2,
"a",
4,
5,
100,
"nice"
]
Selector:
$[3:-2]
Consensus:
[
5
]
Test Data:
[
"first",
"second",
"third",
"forth"
]
Selector:
$[2:1]
Consensus:
[]
Test Data:
[
"first",
"second"
]
Selector:
$[0:0]
Consensus:
[]
Test Data:
[
"first",
"second"
]
Selector:
$[0:1]
Consensus:
[
"first"
]
Test Data:
[
"first",
"second",
"third"
]
Selector:
$[-1:]
Consensus:
[
"third"
]
Test Data:
[
"first",
"second",
"third"
]
Selector:
$[-2:]
Consensus:
[
"second",
"third"
]
Test Data:
[
"first",
"second",
"third"
]
Selector:
$[-4:]
Consensus:
[
"first",
"second",
"third"
]
Test Data:
[
"first",
"second",
"third",
"forth",
"fifth"
]
Selector:
$[0:3:2]
Consensus:
[
"first",
"third"
]
Test Data:
[
"first",
"second",
"third",
"forth",
"fifth"
]
Selector:
$[0:3:1]
Consensus:
[
"first",
"second",
"third"
]
Test Data:
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25
]
Selector:
$[010:024:010]
Consensus:
[
10,
20
]
Test Data:
[
"first",
"second",
"third",
"forth",
"fifth"
]
Selector:
$[0:4:2]
Consensus:
[
"first",
"third"
]
Test Data:
[
"first",
"second",
"third",
"forth",
"fifth"
]
Selector:
$[1:3:]
Consensus:
[
"second",
"third"
]
Test Data:
[
"first",
"second",
"third",
"forth",
"fifth"
]
Selector:
$[::2]
Consensus:
[
"first",
"third",
"fifth"
]
Bracket Notation
# Bracket Notation
Test Data:
{
"key": "value"
}
Selector:
$['key']
Consensus:
[
"value"
]
Test Data:
[
"first",
{
"key": [
"first nested",
{
"more": [
{
"nested": [
"deepest",
"second"
]
},
[
"more",
"values"
]
]
}
]
}
]
Selector:
$..[0]
Consensus:
[
"deepest",
"first nested",
"first",
"more",
{
"nested": [
"deepest",
"second"
]
}
]
Test Data:
{
"key": "value"
}
Selector:
$['missing']
Consensus:
[]
Test Data:
{
"u\u0308": 42
}
Selector:
$['ü']
Consensus:
[]
Test Data:
{
"one": {
"key": "value"
},
"two": {
"some": "more",
"key": "other value"
},
"two.some": "42"
}
Selector:
$['two.some']
Consensus:
[
"42"
]
Test Data:
{
"key": "value"
}
Selector:
$["key"]
Consensus:
[
"value"
]
Test Data:
{
"": 42,
"''": 123,
"\"\"": 222
}
Selector:
$['']
Consensus:
[
42
]
Test Data:
{
"": 42,
"''": 123,
"\"\"": 222
}
Selector:
$[""]
Consensus:
[
42
]
Test Data:
[
"one element"
]
Selector:
$[-2]
Consensus:
[]
Test Data:
[
"first",
"second",
"third",
"forth",
"fifth"
]
Selector:
$[2]
Consensus:
[
"third"
]
Test Data:
[
"first",
"second",
"third"
]
Selector:
$[-1]
Consensus:
[
"third"
]
Test Data:
[]
Selector:
$[-1]
Consensus:
[]
Test Data:
[
"first",
"second",
"third",
"forth",
"fifth"
]
Selector:
$[0]
Consensus:
[
"first"
]
Bracket Notation With Number After Dot Notation With Wildcard On Nested Arrays With Different Length
Test Data:
[
[
1
],
[
2,
3
]
]
Selector:
$.*[1]
Consensus:
[
3
]
Test Data:
[
"one element"
]
Selector:
$[1]
Consensus:
[]
Test Data:
{
":": "value",
"another": "entry"
}
Selector:
$[':']
Consensus:
[
"value"
]
Test Data:
{
"]": 42
}
Selector:
$[']']
Consensus:
[
42
]
Test Data:
{
"@": "value",
"another": "entry"
}
Selector:
$['@']
Consensus:
[
"value"
]
Test Data:
{
".": "value",
"another": "entry"
}
Selector:
$['.']
Consensus:
[
"value"
]
Test Data:
{
"key": 42,
".*": 1,
"": 10
}
Selector:
$['.*']
Consensus:
[
1
]
Test Data:
{
"\"": "value",
"another": "entry"
}
Selector:
$['"']
Consensus:
[
"value"
]
Test Data:
{
"0": "value"
}
Selector:
$['0']
Consensus:
[
"value"
]
Test Data:
{
"$": "value",
"another": "entry"
}
Selector:
$['$']
Consensus:
[
"value"
]
Test Data:
{
",": "value",
"another": "entry"
}
Selector:
$[',']
Consensus:
[
"value"
]
Test Data:
{
"*": "value",
"another": "entry"
}
Selector:
$['*']
Consensus:
[
"value"
]
Test Data:
{
"nice": 42,
"ni.*": 1,
"mice": 100
}
Selector:
$['ni.*']
Consensus:
[
1
]
Test Data:
[
[
1,
2
],
[
"a",
"b"
],
[
0,
0
]
]
Selector:
$[0:2][*]
Consensus:
[
1,
2,
"a",
"b"
]
Test Data:
[
{
"bar": [
42
]
}
]
Selector:
$[*].bar[*]
Consensus:
[
42
]
Test Data:
{
"key": "value",
"another key": {
"complex": "string",
"primitives": [
0,
1
]
}
}
Selector:
$..[*]
Consensus:
[
"string",
"value",
0,
1,
[
0,
1
],
{
"complex": "string",
"primitives": [
0,
1
]
}
]
Test Data:
[
"string",
42,
{
"key": "value"
},
[
0,
1
]
]
Selector:
$[*]
Consensus:
[
"string",
42,
{
"key": "value"
},
[
0,
1
]
]
Test Data:
[]
Selector:
$[*]
Consensus:
[]
Test Data:
{}
Selector:
$[*]
Consensus:
[]
Test Data:
[
40,
null,
42
]
Selector:
$[*]
Consensus:
[
40,
null,
42
]
Test Data:
{
"some": "string",
"int": 42,
"object": {
"key": "value"
},
"array": [
0,
1
]
}
Selector:
$[*]
Consensus:
[
"string",
42,
[
0,
1
],
{
"key": "value"
}
]
Dot Notation
# Dot Notation
Test Data:
{
"key": "value"
}
Selector:
$.key
Consensus:
[
"value"
]
Test Data:
[
{
"key": "ey"
},
{
"key": "bee"
},
{
"key": "see"
}
]
Selector:
$[0:2].key
Consensus:
[
"ey",
"bee"
]
Test Data:
{
"k": [
{
"key": "some value"
},
{
"key": 42
}
],
"kk": [
[
{
"key": 100
},
{
"key": 200
},
{
"key": 300
}
],
[
{
"key": 400
},
{
"key": 500
},
{
"key": 600
}
]
],
"key": [
0,
1
]
}
Selector:
$..[1].key
Consensus:
[
200,
42,
500
]
Test Data:
[
{
"a": 1
},
{
"a": 1
}
]
Selector:
$[*].a
Consensus:
[
1,
1
]
Test Data:
[
{
"a": 1
}
]
Selector:
$[*].a
Consensus:
[
1
]
Test Data:
[
{
"a": 1
},
{
"b": 1
}
]
Selector:
$[*].a
Consensus:
[
1
]
Test Data:
[
{
"id": 42,
"name": "forty-two"
},
{
"id": 1,
"name": "one"
}
]
Selector:
$[?(@.id==42)].name
Consensus:
[
"forty-two"
]
Test Data:
{
"object": {
"key": "value",
"array": [
{
"key": "something"
},
{
"key": {
"key": "russian dolls"
}
}
]
},
"key": "top"
}
Selector:
$..key
Consensus:
[
"russian dolls",
"something",
"top",
"value",
{
"key": "russian dolls"
}
]
Test Data:
{
"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
}
}
}
Selector:
$.store..price
Consensus:
[
12.99,
19.95,
22.99,
8.95,
8.99
]
Test Data:
[
{
"key": "ey"
},
{
"key": "bee"
},
{
"key": "see"
}
]
Selector:
$[0,2].key
Consensus:
[
"ey",
"see"
]
Test Data:
{
"one": {
"key": "value"
},
"two": {
"k": "v"
},
"three": {
"some": "more",
"key": "other value"
}
}
Selector:
$['one','three'].key
Consensus:
[
"value",
"other value"
]
Test Data:
[
0,
1
]
Selector:
$.key
Consensus:
[]
Test Data:
{
"key": [
"first",
"second"
]
}
Selector:
$.key
Consensus:
[
[
"first",
"second"
]
]
Test Data:
[
{
"id": 2
}
]
Selector:
$.id
Consensus:
[]
Test Data:
{
"key": {}
}
Selector:
$.key
Consensus:
[
{}
]
Test Data:
{
"key": null
}
Selector:
$.key
Consensus:
[
null
]
Test Data:
{
"key": "value"
}
Selector:
$.missing
Consensus:
[]
Test Data:
{
"key-dash": "value"
}
Selector:
$.key-dash
Consensus:
[
"value"
]
Test Data:
{
"in": "value"
}
Selector:
$.in
Consensus:
[
"value"
]
Test Data:
{
"length": "value"
}
Selector:
$.length
Consensus:
[
"value"
]
Test Data:
[
4,
5,
6
]
Selector:
$.length
Consensus:
[]
Test Data:
{
"null": "value"
}
Selector:
$.null
Consensus:
[
"value"
]
Test Data:
{
"true": "value"
}
Selector:
$.true
Consensus:
[
"value"
]
Test Data:
{
"\u5c6c\u6027": "value"
}
Selector:
$.屬性
Consensus:
[
"value"
]
Test Data:
{
"a": "first",
"2": "second",
"b": "third"
}
Selector:
$.2
Consensus:
[
"second"
]
Test Data:
[
{
"bar": [
42
]
}
]
Selector:
$.*.bar.*
Consensus:
[
42
]
Test Data:
[
[
1,
2,
3
],
[
4,
5,
6
]
]
Selector:
$.*.*
Consensus:
[
1,
2,
3,
4,
5,
6
]
Test Data:
{
"key": "value",
"another key": {
"complex": "string",
"primitives": [
0,
1
]
}
}
Selector:
$..*
Consensus:
[
"string",
"value",
0,
1,
[
0,
1
],
{
"complex": "string",
"primitives": [
0,
1
]
}
]
Test Data:
[
40,
null,
42
]
Selector:
$..*
Consensus:
[
40,
42,
null
]
Test Data:
42
Selector:
$..*
Consensus:
[]
Test Data:
[
"string",
42,
{
"key": "value"
},
[
0,
1
]
]
Selector:
$.*
Consensus:
[
"string",
42,
{
"key": "value"
},
[
0,
1
]
]
Test Data:
[]
Selector:
$.*
Consensus:
[]
Test Data:
{}
Selector:
$.*
Consensus:
[]
Test Data:
{
"some": "string",
"int": 42,
"object": {
"key": "value"
},
"array": [
0,
1
]
}
Selector:
$.*
Consensus:
[
"string",
42,
[
0,
1
],
{
"key": "value"
}
]
Filter Expression
# Filter Expression With Bracket Notation
Test Data:
[
{
"key": 0
},
{
"key": 42
},
{
"key": -1
},
{
"key": 41
},
{
"key": 43
},
{
"key": 42.0001
},
{
"key": 41.9999
},
{
"key": 100
},
{
"some": "value"
}
]
Selector:
$[?(@['key']==42)]
Consensus:
[
{
"key": 42
}
]
Test Data:
[
{
"@key": 0
},
{
"@key": 42
},
{
"key": 42
},
{
"@key": 43
},
{
"some": "value"
}
]
Selector:
$[?(@['@key']==42)]
Consensus:
[
{
"@key": 42
}
]
Test Data:
[
[
"a",
"b"
],
[
"x",
"y"
]
]
Selector:
$[?(@[1]=='b')]
Consensus:
[
[
"a",
"b"
]
]
Test Data:
[
{
"key": 42
}
]
Selector:
$[?(@.key==43)]
Consensus:
[]
Test Data:
[
{
"key": "some"
},
{
"key": "value"
},
{
"key": "[email protected]"
}
]
Selector:
$[?(@.key=="[email protected]")]
Consensus:
[
{
"key": "[email protected]"
}
]
Test Data:
[
{
"key": "some"
},
{
"key": "value"
},
{
"key": "some.value"
}
]
Selector:
$[?(@.key=="some.value")]
Consensus:
[
{
"key": "some.value"
}
]
Test Data:
[
{
"key": "some"
},
{
"key": "value"
}
]
Selector:
$[?(@.key=='value')]
Consensus:
[
{
"key": "value"
}
]
Test Data:
[
{
"address": {
"city": "Berlin"
}
},
{
"address": {
"city": "London"
}
}
]
Selector:
$[?(@.address.city=='Berlin')]
Consensus:
[
{
"address": {
"city": "Berlin"
}
}
]
Root
# Root
Test Data:
{
"key": "value",
"another key": {
"complex": [
"a",
1
]
}
}
Selector:
$
Consensus:
[
{
"another key": {
"complex": [
"a",
1
]
},
"key": "value"
}
]
Test Data:
42
Selector:
$
Consensus:
[
42
]
Test Data:
false
Selector:
$
Consensus:
[
false
]
Test Data:
true
Selector:
$
Consensus:
[
true
]
Union
# Union
Test Data:
[
"first",
"second",
"third"
]
Selector:
$[0,1]
Consensus:
[
"first",
"second"
]
Test Data:
{
"key": "value",
"another": "entry"
}
Selector:
$['key','another']
Consensus:
[
"value",
"entry"
]
Test Data:
[
{
"c": "cc1",
"d": "dd1",
"e": "ee1"
},
{
"c": "cc2",
"d": "dd2",
"e": "ee2"
}
]
Selector:
$[:]['c','d']
Consensus:
[
"cc1",
"dd1",
"cc2",
"dd2"
]
Test Data:
[
{
"c": "cc1",
"d": "dd1",
"e": "ee1"
},
{
"c": "cc2",
"d": "dd2",
"e": "ee2"
}
]
Selector:
$[0]['c','d']
Consensus:
[
"cc1",
"dd1"
]
Test Data:
{
"key": "value",
"another": "entry"
}
Selector:
$['missing','key']
Consensus:
[
"value"
]
Test Data:
[
1,
2,
3,
4,
5
]
Selector:
$[4,1]
Consensus:
[
5,
2
]
Test Data:
[
"first",
"second",
"third"
]
Selector:
$[ 0 , 1 ]
Consensus:
[
"first",
"second"
]