Skip to content

Latest commit

 

History

History

test

Consensus Tests

This test package has tests detailed by https://cburgmer.github.io/json-path-comparison/ comparison matrix which details the community consensus on the expected response from multiple JSONPath queries by various implementations.

This implementation would be closer to the 'Scalar consensus' as it does not always return an array, but instead can return a single item when that is expected.

Array Test

match selector data consensus actual
$[1:3] ["first", "second", "third", "forth", "fifth"] ["second","third"] ["second","third"]
$[0:5] ["first", "second", "third", "forth", "fifth"] ["first","second","third","forth","fifth"] ["first","second","third","forth","fifth"]
$[7:10] ["first", "second", "third"] [] []
$[1:3] {":": 42, "more": "string", "a": 1, "b": 2, "c": 3, "1:3": "nice"} nil null
$[1:10] ["first", "second", "third"] ["second","third"] ["second","third"]
$[2:113667776004] ["first", "second", "third", "forth", "fifth"] ["third","forth","fifth"] ["third","forth","fifth"]
$[2:-113667776004:-1] ["first", "second", "third", "forth", "fifth"] none []
$[-113667776004:2] ["first", "second", "third", "forth", "fifth"] ["first","second"] ["first","second"]
$[113667776004:2:-1] ["first", "second", "third", "forth", "fifth"] [] []
$[-4:-5] [2, "a", 4, 5, 100, "nice"] [] []
$[-4:-4] [2, "a", 4, 5, 100, "nice"] [] []
$[-4:-3] [2, "a", 4, 5, 100, "nice"] [4] [4]
$[-4:1] [2, "a", 4, 5, 100, "nice"] [] []
$[-4:2] [2, "a", 4, 5, 100, "nice"] [] []
$[-4:3] [2, "a", 4, 5, 100, "nice"] [4] [4]
$[3:0:-2] ["first", "second", "third", "forth", "fifth"] [] []
$[7:3:-1] ["first", "second", "third", "forth", "fifth"] [] []
$[0:3:-2] ["first", "second", "third", "forth", "fifth"] none ["third","first"]
$[::-2] ["first", "second", "third", "forth", "fifth"] none ["fifth","third","first"]
$[1:] ["first", "second", "third", "forth", "fifth"] ["second","third","forth","fifth"] ["second","third","forth","fifth"]
$[3::-1] ["first", "second", "third", "forth", "fifth"] none ["fifth","forth"]
$[:2] ["first", "second", "third", "forth", "fifth"] ["first","second"] ["first","second"]
$[:] ["first","second"] ["first","second"] ["first","second"]
$[:] {":": 42, "more": "string"} nil null
$[::] ["first","second"] ["first","second"] ["first","second"]
$[:2:-1] ["first", "second", "third", "forth", "fifth"] none ["second","first"]
$[3:-4] [2, "a", 4, 5, 100, "nice"] [] []
$[3:-3] [2, "a", 4, 5, 100, "nice"] [] []
$[3:-2] [2, "a", 4, 5, 100, "nice"] [5] [5]
$[2:1] ["first", "second", "third", "forth"] [] []
$[0:0] ["first", "second"] [] []
$[0:1] ["first", "second"] ["first"] ["first"]
$[-1:] ["first", "second", "third"] ["third"] ["third"]
$[-2:] ["first", "second", "third"] ["second","third"] ["second","third"]
$[-4:] ["first", "second", "third"] ["first","second","third"] ["first","second","third"]
$[0:3:2] ["first", "second", "third", "forth", "fifth"] ["first","third"] ["first","third"]
$[0:3:0] ["first", "second", "third", "forth", "fifth"] none null
$[0:3:1] ["first", "second", "third", "forth", "fifth"] ["first","second","third"] ["first","second","third"]
$[010:024:010] [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] [10,20] [10,20]
$[0:4:2] ["first", "second", "third", "forth", "fifth"] ["first","third"] ["first","third"]
$[1:3:] ["first", "second", "third", "forth", "fifth"] ["second","third"] ["second","third"]
$[::2] ["first", "second", "third", "forth", "fifth"] ["first","third","fifth"] ["first","third","fifth"]

Bracket Test

match selector data consensus actual
$['key'] {"key": "value"} "value" "value"
$['missing'] {"key": "value"} nil null
$..[0] [ "first", { "key": [ "first nested", { "more": [ { "nested": ["deepest", "second"] }, ["more", "values"] ] } ] } ] ["deepest","first nested","first","more",{"nested":["deepest","second"]}] ["deepest","first nested","first","more",{"nested":["deepest","second"]}]
$['ü'] {"ü": 42} nil null
$['two.some'] { "one": {"key": "value"}, "two": {"some": "more", "key": "other value"}, "two.some": "42" } "42" "42"
$["key"] {"key": "value"} "value" "value"
$[] {"": 42, "''": 123, "\"\"": 222} nil null
$[''] {"": 42, "''": 123, "\"\"": 222} 42 42
$[""] {"": 42, "''": 123, "\"\"": 222} 42 42
$[-2] ["one element"] nil null
$[2] ["first", "second", "third", "forth", "fifth"] "third" "third"
$[0] { "0": "value" } nil null
$[1] ["one element"] nil null
$[0] Hello World nil null
$.*[1] [[1], [2,3]] [3] [3]
$[-1] ["first", "second", "third"] "third" "third"
$[-1] [] nil null
$[0] ["first", "second", "third", "forth", "fifth"] "first" "first"
$[':'] { ":": "value", "another": "entry" } "value" "value"
$[']'] {"]": 42} 42 42
$['@'] { "@": "value", "another": "entry" } "value" "value"
$['.'] { ".": "value", "another": "entry" } "value" "value"
$['.*'] {"key": 42, ".*": 1, "": 10} 1 1
$['"'] { "\"": "value", "another": "entry" } "value" "value"
$['\\'] {"\\":"value"} none "value"
$['\''] {"'":"value"} "value" "value"
$['0'] { "0": "value" } "value" "value"
$['$'] { "$": "value", "another": "entry" } "value" "value"
$[':@."$,*\'\\'] {":@.\"$,*'\\": 42} none 42
$['single'quote'] {"single'quote":"value"} nil null
$[','] { ",": "value", "another": "entry" } "value" "value"
$['*'] { "*": "value", "another": "entry" } "value" "value"
$['*'] { "another": "entry" } nil null
$[ 'a' ] {" a": 1, "a": 2, " a ": 3, "a ": 4, " 'a' ": 5, " 'a": 6, "a' ": 7, " \"a\" ": 8, "\"a\"": 9} 2 2
$['ni.*'] {"nice": 42, "ni.*": 1, "mice": 100} 1 1
$['two'.'some'] { "one": {"key": "value"}, "two": {"some": "more", "key": "other value"}, "two.some": "42", "two'.'some": "43" } nil null
$[two.some] { "one": {"key": "value"}, "two": {"some": "more", "key": "other value"}, "two.some": "42" } nil null
$[*] [ "string", 42, { "key": "value" }, [0, 1] ] ["string",42,{"key":"value"},[0,1]] ["string",42,{"key":"value"},[0,1]]
$[*] [] [] []
$[*] {} [] []
$[*] [ 40, null, 42 ] [40,null,42] [40,null,42]
$[*] { "some": "string", "int": 42, "object": { "key": "value" }, "array": [0, 1] } ["string",42,{"key":"value"},[0,1]] ["string",42,{"key":"value"},[0,1]]
$[0:2][*] [[1, 2], ["a", "b"], [0, 0]] [1,2,"a","b"] [[1,2],["a","b"]]
$[*].bar[*] [{"bar": [42]}] [42] [[42]]
$..[*] { "key": "value", "another key": { "complex": "string", "primitives": [0, 1] } } ["value",{"complex":"string","primitives":[0,1]},[0,1],"string",0,1] ["value",{"complex":"string","primitives":[0,1]},[0,1],"string",0,1]
$[key] { "key": "value" } nil null

Dot Test

match selector data consensus actual
@.a {"a": 1} nil 1
$.['key'] { "key": "value", "other": {"key": [{"key": 42}]} } "value" "value"
$.["key"] { "key": "value", "other": {"key": [{"key": 42}]} } none "value"
$.[key] { "key": "value", "other": {"key": [{"key": 42}]} } none null
$.key { "key": "value" } "value" "value"
$.key [0, 1] nil null
$.key { "key": ["first", "second"] } ["first","second"] ["first","second"]
$.id [{"id": 2}] nil null
$.key { "key": {} } {} {}
$.key { "key": null } nil null
$.missing {"key": "value"} nil null
$[0:2].key [{"key": "ey"}, {"key": "bee"}, {"key": "see"}] ["ey","bee"] ["ey","bee"]
$..[1].key { "k": [{"key": "some value"}, {"key": 42}], "kk": [[{"key": 100}, {"key": 200}, {"key": 300}], [{"key": 400}, {"key": 500}, {"key": 600}]], "key": [0, 1] } [200,42,500] [200,42,500]
$[*].a [{"a": 1},{"a": 1}] [1,1] [1,1]
$[*].a [{"a": 1}] [1] [1]
$[*].a [{"a": 1},{"b": 1}] [1] [1]
$[?(@.id==42)].name [{"id": 42, "name": "forty-two"}, {"id": 1, "name": "one"}] ["forty-two"] ["forty-two"]
$..key { "object": { "key": "value", "array": [ {"key": "something"}, {"key": {"key": "russian dolls"}} ] }, "key": "top" } ["russian dolls","something","top","value",{"key":"russian dolls"}] ["russian dolls","something","top","value",{"key":"russian dolls"}]
$.store..price { "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 } } } [12.99,19.95,22.99,8.95,8.99] [12.99,19.95,22.99,8.95,8.99]
$...key { "object": { "key": "value", "array": [ {"key": "something"}, {"key": {"key": "russian dolls"}} ] }, "key": "top" } ["russian dolls","something","top","value"] ["russian dolls","something","top","value",{"key":"russian dolls"}]
$[0,2].key [{"key": "ey"}, {"key": "bee"}, {"key": "see"}] ["ey","see"] ["ey","see"]
$['one','three'].key { "one": {"key": "value"}, "two": {"k": "v"}, "three": {"some": "more", "key": "other value"} } ["value","other value"] ["value","other value"]
$.key-dash { "key": 42, "key-": 43, "-": 44, "dash": 45, "-dash": 46, "": 47, "key-dash": "value", "something": "else" } "value" "value"
$."key" { "key": "value", "\"key\"": 42 } none 42
$.."key" { "object": { "key": "value", "\"key\"": 100, "array": [ {"key": "something", "\"key\"": 0}, {"key": {"key": "russian dolls"}, "\"key\"": {"\"key\"": 99}} ] }, "key": "top", "\"key\"": 42 } none [0,42,99,100,{"\"key\"":99}]
$. {"key": 42, "": 9001, "''": "nice"} none null
$.in { "in": "value" } "value" "value"
$.length { "length": "value" } "value" "value"
$.length [4, 5, 6] nil 3
$.null { "null": "value" } "value" "value"
$.true { "true": "value" } "value" "value"
$.$ { "$": "value" } none {"$":"value"}
$.屬性 { "屬性": "value" } "value" "value"
$.2 ["first", "second", "third", "forth", "fifth"] none null
$.2 {"a": "first", "2": "second", "b": "third"} "second" "second"
$.-1 ["first", "second", "third", "forth", "fifth"] nil null
$.'key' { "key": "value", "'key'": 42 } none 42
$..'key' { "object": { "key": "value", "'key'": 100, "array": [ {"key": "something", "'key'": 0}, {"key": {"key": "russian dolls"}, "'key'": {"'key'": 99}} ] }, "key": "top", "'key'": 42 } none [42,100,0,{"'key'":99},99]
$.'some.key' {"some.key": 42, "some": {"key": "value"}, "'some.key'": 43} none 43
$. a {" a": 1, "a": 2, " a ": 3, "": 4} none 2
$.* [ "string", 42, { "key": "value" }, [0, 1] ] ["string",42,{"key":"value"},[0,1]] ["string",42,{"key":"value"},[0,1]]
$.* [] [] []
$.* {} [] []
$.* { "some": "string", "int": 42, "object": { "key": "value" }, "array": [0, 1] } ["string",42,[0,1],{"key":"value"}] ["string",42,[0,1],{"key":"value"}]
$.*.bar.* [{"bar": [42]}] [42] [[42]]
$.*.* [[1, 2, 3], [4, 5, 6]] [1,2,3,4,5,6] [[1,2,3],[4,5,6]]
$..* { "key": "value", "another key": { "complex": "string", "primitives": [0, 1] } } ["string","value",0,1,[0,1],{"complex":"string","primitives":[0,1]}] ["string","value",0,1,[0,1],{"complex":"string","primitives":[0,1]}]
$..* [ 40, null, 42 ] [40,42,null] [40,42,null]
$..* 42 [] []
$a {"a": 1, "$a": 2} nil null
.key { "key": "value" } nil null
key { "key": "value" } nil null

Filter Test

match selector data consensus actual
$[?(@.key)] {"key": 42, "another": {"key": 1}} none [{"key":1}]
$..*[?(@.id>2)] [ { "complext": { "one": [ { "name": "first", "id": 1 }, { "name": "next", "id": 2 }, { "name": "another", "id": 3 }, { "name": "more", "id": 4 } ], "more": { "name": "next to last", "id": 5 } } }, { "name": "last", "id": 6 } ] none [[],[],[{"id":5,"name":"next to last"}],[{"id":3,"name":"another"},{"id":4,"name":"more"}],[],[],[],[],[]]
$..[?(@.id==2)] {"id": 2, "more": [{"id": 2}, {"more": {"id": 2}}, {"id": {"id": 2}}, [{"id": 2}]]} none [{"id":2},{"id":2},{"id":2},{"id":2}]
$[?(@.key+50==100)] [{"key": 60}, {"key": 50}, {"key": 10}, {"key": -50}, {"key+50": 100}] none [{"key":50}]
$[?(@.key>42 && @.key<44)] [ {"key": 42}, {"key": 43}, {"key": 44} ] [{"key":43}] [{"key":43}]
$[?(@.key>0 && false)] [ {"key": 1}, {"key": 3}, {"key": "nice"}, {"key": true}, {"key": null}, {"key": false}, {"key": {}}, {"key": []}, {"key": -1}, {"key": 0}, {"key": ""} ] none []
$[?(@.key>0 && true)] [ {"key": 1}, {"key": 3}, {"key": "nice"}, {"key": true}, {"key": null}, {"key": false}, {"key": {}}, {"key": []}, {"key": -1}, {"key": 0}, {"key": ""} ] none [{"key":1},{"key":3}]
$[?(@.key>43 || @.key<43)] [ {"key": 42}, {"key": 43}, {"key": 44} ] [{"key":42},{"key":44}] [{"key":42},{"key":44}]
$[?(@.key>0 || false)] [ {"key": 1}, {"key": 3}, {"key": "nice"}, {"key": true}, {"key": null}, {"key": false}, {"key": {}}, {"key": []}, {"key": -1}, {"key": 0}, {"key": ""} ] none [{"key":1},{"key":3}]
$[?(@.key>0 || true)] [ {"key": 1}, {"key": 3}, {"key": "nice"}, {"key": true}, {"key": null}, {"key": false}, {"key": {}}, {"key": []}, {"key": -1}, {"key": 0}, {"key": ""} ] none [{"key":1},{"key":3},{"key":-1},{"key":0}]
$[?(@['key']==42)] [ {"key": 0}, {"key": 42}, {"key": -1}, {"key": 41}, {"key": 43}, {"key": 42.0001}, {"key": 41.9999}, {"key": 100}, {"some": "value"} ] [{"key":42}] [{"key":42}]
$[?(@['@key']==42)] [ {"@key": 0}, {"@key": 42}, {"key": 42}, {"@key": 43}, {"some": "value"} ] [{"@key":42}] [{"@key":42}]
$[?(@[-1]==2)] [[2, 3], ["a"], [0, 2], [2]] none [[0,2],[2]]
$[?(@[1]=='b')] [["a", "b"], ["x", "y"]] [["a","b"]] [["a","b"]]
$[?(@[1]=='b')] {"1": ["a", "b"], "2": ["x", "y"]} none [["a","b"]]
$[?(@)] [ "some value", null, "value", 0, 1, -1, "", [], {}, false, true ] none ["some value","value",1,-1,true]
$[?(@.a && (@.b || @.c))] [ { "a": true }, { "a": true, "b": true }, { "a": true, "b": true, "c": true }, { "b": true, "c": true }, { "a": true, "c": true }, { "c": true }, { "b": true } ] none [{"a":true,"b":true,"c":true}]
[?(@.a && @.b || @.c)] [ { "a": true, "b": true }, { "a": true, "b": true, "c": true }, { "b": true, "c": true }, { "a": true, "c": true }, { "a": true }, { "b": true }, { "c": true }, { "d": true }, {} ] none null
$[?(@.key/10==5)] [{"key": 60}, {"key": 50}, {"key": 10}, {"key": -50}, {"key/10": 5}] none [{"key":50}]
$[?(@.key-dash == 'value')] [ { "key-dash": "value" } ] none []
$[?(@.2 == 'second')] [{"a": "first", "2": "second", "b": "third"}] none [{"2":"second","a":"first","b":"third"}]
$[?(@.2 == 'third')] [["first", "second", "third", "forth", "fifth"]] none []
$[?()] [1, {"key": 42}, "value", null] nil null
$[?(@.key==42)] [ {"key": 0}, {"key": 42}, {"key": -1}, {"key": 1}, {"key": 41}, {"key": 43}, {"key": 42.0001}, {"key": 41.9999}, {"key": 100}, {"key": "some"}, {"key": "42"}, {"key": null}, {"key": 420}, {"key": ""}, {"key": {}}, {"key": []}, {"key": [42]}, {"key": {"key": 42}}, {"key": {"some": 42}}, {"some": "value"} ] none [{"key":42}]
$[?(@==42)] [ 0, 42, -1, 41, 43, 42.0001, 41.9999, null, 100 ] [42] [42]
$[?(@.key==43)] [{"key": 42}] [] []
$[?(@.key==42)] { "a": {"key": 0}, "b": {"key": 42}, "c": {"key": -1}, "d": {"key": 41}, "e": {"key": 43}, "f": {"key": 42.0001}, "g": {"key": 41.9999}, "h": {"key": 100}, "i": {"some": "value"} } none [{"key":42}]
$[?(@.id==2)] {"id": 2} none []
$[?(@.d==["v1","v2"])] [ { "d": [ "v1", "v2" ] }, { "d": [ "a", "b" ] }, { "d": "v1" }, { "d": "v2" }, { "d": {} }, { "d": [] }, { "d": null }, { "d": -1 }, { "d": 0 }, { "d": 1 }, { "d": "['v1','v2']" }, { "d": "['v1', 'v2']" }, { "d": "v1,v2" }, { "d": "[\"v1\", \"v2\"]" }, { "d": "[\"v1\",\"v2\"]" } ] none [{"d":["v1","v2"]}]
$[?(@[0:1]==[1])] [[1, 2, 3], [1], [2, 3], 1, 2] none [[1,2,3],[1]]
$[?(@.*==[1,2])] [[1,2], [2,3], [1], [2], [1, 2, 3], 1, 2, 3] none [[1,2]]
$[?(@.d==['v1','v2'])] [ { "d": [ "v1", "v2" ] }, { "d": [ "a", "b" ] }, { "d": "v1" }, { "d": "v2" }, { "d": {} }, { "d": [] }, { "d": null }, { "d": -1 }, { "d": 0 }, { "d": 1 }, { "d": "['v1','v2']" }, { "d": "['v1', 'v2']" }, { "d": "v1,v2" }, { "d": "[\"v1\", \"v2\"]" }, { "d": "[\"v1\",\"v2\"]" } ] none []
$[?((@.key<44)==false)] [{"key": 42}, {"key": 43}, {"key": 44}] none [{"key":44}]
$[?(@.key==false)] [ { "some": "some value" }, { "key": true }, { "key": false }, { "key": null }, { "key": "value" }, { "key": "" }, { "key": 0 }, { "key": 1 }, { "key": -1 }, { "key": 42 }, { "key": {} }, { "key": [] } ] none [{"key":false}]
$[?(@.key==null)] [ { "some": "some value" }, { "key": true }, { "key": false }, { "key": null }, { "key": "value" }, { "key": "" }, { "key": 0 }, { "key": 1 }, { "key": -1 }, { "key": 42 }, { "key": {} }, { "key": [] } ] none [{"key":null}]
$[?(@[0:1]==1)] [[1, 2, 3], [1], [2, 3], 1, 2] none []
$[?(@[*]==2)] [[1,2], [2,3], [1], [2], [1, 2, 3], 1, 2, 3] none []
$[?(@.*==2)] [[1,2], [2,3], [1], [2], [1, 2, 3], 1, 2, 3] none []
$[?(@.key==-0.123e2)] [{"key": -12.3}, {"key": -0.123}, {"key": -12}, {"key": 12.3}, {"key": 2}, {"key": "-0.123e2"}] none [{"key":-12.3}]
$[?(@.key==010)] [{"key": "010"}, {"key": "10"}, {"key": 10}, {"key": 0}, {"key": 8}] none [{"key":10}]
$[?(@.d=={"k":"v"})] [ { "d": { "k": "v" } }, { "d": { "a": "b" } }, { "d": "k" }, { "d": "v" }, { "d": {} }, { "d": [] }, { "d": null }, { "d": -1 }, { "d": 0 }, { "d": 1 }, { "d": "[object Object]" }, { "d": "{\"k\": \"v\"}" }, { "d": "{\"k\":\"v\"}" }, "v" ] none [{"d":{"k":"v"}}]
$[?(@.key=="value")] [ {"key": "some"}, {"key": "value"}, {"key": null}, {"key": 0}, {"key": 1}, {"key": -1}, {"key": ""}, {"key": {}}, {"key": []}, {"key": "valuemore"}, {"key": "morevalue"}, {"key": ["value"]}, {"key": {"some": "value"}}, {"key": {"key": "value"}}, {"some": "value"} ] [{"key":"value"}] [{"key":"value"}]
$[?(@.key=="Motörhead")] [ {"key": "something"}, {"key": "Mot\u00f6rhead"}, {"key": "mot\u00f6rhead"}, {"key": "Motorhead"}, {"key": "Motoo\u0308rhead"}, {"key": "motoo\u0308rhead"} ] [{"key":"Motörhead"}] [{"key":"Motörhead"}]
$[?(@.key=="hi@example.com")] [ {"key": "some"}, {"key": "value"}, {"key": "hi@example.com"} ] [{"key":"hi@example.com"}] [{"key":"hi@example.com"}]
$[?(@.key=="some.value")] [ {"key": "some"}, {"key": "value"}, {"key": "some.value"} ] [{"key":"some.value"}] [{"key":"some.value"}]
$[?(@.key=='value')] [ {"key": "some"}, {"key": "value"} ] [{"key":"value"}] [{"key":"value"}]
$[?(@.key=="Mot\u00f6rhead")] [ {"key": "something"}, {"key": "Mot\u00f6rhead"}, {"key": "mot\u00f6rhead"}, {"key": "Motorhead"}, {"key": "Motoo\u0308rhead"}, {"key": "motoo\u0308rhead"} ] none []
$[?(@.key==true)] [ { "some": "some value" }, { "key": true }, { "key": false }, { "key": null }, { "key": "value" }, { "key": "" }, { "key": 0 }, { "key": 1 }, { "key": -1 }, { "key": 42 }, { "key": {} }, { "key": [] } ] none [{"key":true}]
$[?(@.key1==@.key2)] [ {"key1": 10, "key2": 10}, {"key1": 42, "key2": 50}, {"key1": 10}, {"key2": 10}, {}, {"key1": null, "key2": null}, {"key1": null}, {"key2": null}, {"key1": 0, "key2": 0}, {"key1": 0}, {"key2": 0}, {"key1": -1, "key2": -1}, {"key1": "", "key2": ""}, {"key1": false, "key2": false}, {"key1": false}, {"key2": false}, {"key1": true, "key2": true}, {"key1": [], "key2": []}, {"key1": {}, "key2": {}}, {"key1": {"a": 1, "b": 2}, "key2": {"b": 2, "a": 1}} ] none [{"key1":10,"key2":10},{"key1":null,"key2":null},{"key1":0,"key2":0},{"key1":-1,"key2":-1},{"key1":"","key2":""},{"key1":false,"key2":false},{"key1":true,"key2":true},{"key1":[],"key2":[]},{"key1":{},"key2":{}},{"key1":{"a":1,"b":2},"key2":{"a":1,"b":2}}]
$.items[?(@.key==$.value)] {"value": 42, "items": [{"key": 10}, {"key": 42}, {"key": 50}]} none [{"key":42}]
$[?(@.key>42)] [ {"key": 0}, {"key": 42}, {"key": -1}, {"key": 41}, {"key": 43}, {"key": 42.0001}, {"key": 41.9999}, {"key": 100}, {"key": "43"}, {"key": "42"}, {"key": "41"}, {"key": "value"}, {"some": "value"} ] none [{"key":43},{"key":42.0001},{"key":100}]
$[?(@.key>=42)] [ {"key": 0}, {"key": 42}, {"key": -1}, {"key": 41}, {"key": 43}, {"key": 42.0001}, {"key": 41.9999}, {"key": 100}, {"key": "43"}, {"key": "42"}, {"key": "41"}, {"key": "value"}, {"some": "value"} ] none [{"key":42},{"key":43},{"key":42.0001},{"key":100}]
$[?(@.d in [2, 3])] [{"d": 1}, {"d": 2}, {"d": 1}, {"d": 3}, {"d": 4}] nil [{"d":2},{"d":3}]
$[?(2 in @.d)] [{"d": [1, 2, 3]}, {"d": [2]}, {"d": [1]}, {"d": [3, 4]}, {"d": [4, 2]}] nil [{"d":[1,2,3]},{"d":[2]},{"d":[4,2]}]
$[?(@.key<42)] [ {"key": 0}, {"key": 42}, {"key": -1}, {"key": 41}, {"key": 43}, {"key": 42.0001}, {"key": 41.9999}, {"key": 100}, {"key": "43"}, {"key": "42"}, {"key": "41"}, {"key": "value"}, {"some": "value"} ] none [{"key":0},{"key":-1},{"key":41},{"key":41.9999}]
$[?(@.key<=42)] [ {"key": 0}, {"key": 42}, {"key": -1}, {"key": 41}, {"key": 43}, {"key": 42.0001}, {"key": 41.9999}, {"key": 100}, {"key": "43"}, {"key": "42"}, {"key": "41"}, {"key": "value"}, {"some": "value"} ] none [{"key":0},{"key":42},{"key":-1},{"key":41},{"key":41.9999}]
$[?(@.key*2==100)] [{"key": 60}, {"key": 50}, {"key": 10}, {"key": -50}, {"key*2": 100}] none [{"key":50}]
$[?(!(@.key==42))] [ {"key": 0}, {"key": 42}, {"key": -1}, {"key": 41}, {"key": 43}, {"key": 42.0001}, {"key": 41.9999}, {"key": 100}, {"key": "43"}, {"key": "42"}, {"key": "41"}, {"key": "value"}, {"some": "value"} ] none [{"key":0},{"key":-1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"key":100},{"key":"43"},{"key":"42"},{"key":"41"},{"key":"value"}]
$[?(!(@.key<42))] [ {"key": 0}, {"key": 42}, {"key": -1}, {"key": 41}, {"key": 43}, {"key": 42.0001}, {"key": 41.9999}, {"key": 100}, {"key": "43"}, {"key": "42"}, {"key": "41"}, {"key": "value"}, {"some": "value"} ] none [{"key":42},{"key":43},{"key":42.0001},{"key":100}]
$[?(!@.key)] [ { "some": "some value" }, { "key": true }, { "key": false }, { "key": null }, { "key": "value" }, { "key": "" }, { "key": 0 }, { "key": 1 }, { "key": -1 }, { "key": 42 }, { "key": {} }, { "key": [] } ] none [{"key":false},{"key":null},{"key":0}]
$[?(@.key!=42)] [ {"key": 0}, {"key": 42}, {"key": -1}, {"key": 1}, {"key": 41}, {"key": 43}, {"key": 42.0001}, {"key": 41.9999}, {"key": 100}, {"key": "some"}, {"key": "42"}, {"key": null}, {"key": 420}, {"key": ""}, {"key": {}}, {"key": []}, {"key": [42]}, {"key": {"key": 42}}, {"key": {"some": 42}}, {"some": "value"} ] none [{"key":0},{"key":-1},{"key":1},{"key":41},{"key":43},{"key":42.0001},{"key":41.9999},{"key":100},{"key":"some"},{"key":"42"},{"key":null},{"key":420},{"key":""},{"key":{}},{"key":[]},{"key":[42]},{"key":{"key":42}},{"key":{"some":42}}]
$[*].bookmarks[?(@.page == 45)]^^^ [ { "title": "Sayings of the Century", "bookmarks": [{ "page": 40 }] }, { "title": "Sword of Honour", "bookmarks": [ { "page": 35 }, { "page": 45 } ] }, { "title": "Moby Dick", "bookmarks": [ { "page": 3035 }, { "page": 45 } ] } ] nil [[],[],[]]
$[?(@.name=~/hello.*/)] [ {"name": "hullo world"}, {"name": "hello world"}, {"name": "yes hello world"}, {"name": "HELLO WORLD"}, {"name": "good bye"} ] none []
$[?(@.name=~/@.pattern/)] [ {"name": "hullo world"}, {"name": "hello world"}, {"name": "yes hello world"}, {"name": "HELLO WORLD"}, {"name": "good bye"}, {"pattern": "hello.*"} ] none []
$[?(@[*]>=4)] [[1,2],[3,4],[5,6]] none []
$.x[?(@[*]>=$.y[*])] {"x":[[1,2],[3,4],[5,6]],"y":[3,4,5]} none []
$[?(@.key=42)] [ {"key": 0}, {"key": 42}, {"key": -1}, {"key": 1}, {"key": 41}, {"key": 43}, {"key": 42.0001}, {"key": 41.9999}, {"key": 100}, {"key": "some"}, {"key": "42"}, {"key": null}, {"key": 420}, {"key": ""}, {"key": {}}, {"key": []}, {"key": [42]}, {"key": {"key": 42}}, {"key": {"some": 42}}, {"some": "value"} ] nil []
$[?(@.a[?(@.price>10)])] [ { "a": [{"price": 1}, {"price": 3}] }, { "a": [{"price": 11}] }, { "a": [{"price": 8}, {"price": 12}, {"price": 3}] }, { "a": [] } ] none [{"a":[{"price":11}]},{"a":[{"price":8},{"price":12},{"price":3}]}]
$[?(@.address.city=='Berlin')] [ { "address": { "city": "Berlin" } }, { "address": { "city": "London" } } ] [{"address":{"city":"Berlin"}}] [{"address":{"city":"Berlin"}}]
$[?(@.key-50==-100)] [{"key": 60}, {"key": 50}, {"key": 10}, {"key": -50}, {"key-50": -100}] none [{"key":-50}]
$[?(1==1)] [1, 3, "nice", true, null, false, {}, [], -1, 0, ""] none [1,3,"nice",true,null,false,{},[],-1,0,""]
$[?(@.key===42)] [ {"key": 0}, {"key": 42}, {"key": -1}, {"key": 1}, {"key": 41}, {"key": 43}, {"key": 42.0001}, {"key": 41.9999}, {"key": 100}, {"key": "some"}, {"key": "42"}, {"key": null}, {"key": 420}, {"key": ""}, {"key": {}}, {"key": []}, {"key": [42]}, {"key": {"key": 42}}, {"key": {"some": 42}}, {"some": "value"} ] none []
$[?(@.key)] [ { "some": "some value" }, { "key": true }, { "key": false }, { "key": null }, { "key": "value" }, { "key": "" }, { "key": 0 }, { "key": 1 }, { "key": -1 }, { "key": 42 }, { "key": {} }, { "key": [] } ] none [{"key":true},{"key":"value"},{"key":1},{"key":-1},{"key":42}]
$.*[?(@.key)] [ { "some": "some value" }, { "key": "value" } ] none [[],[]]
$..[?(@.id)] {"id": 2, "more": [{"id": 2}, {"more": {"id": 2}}, {"id": {"id": 2}}, [{"id": 2}]]} none [{"id":2},{"id":{"id":2}},{"id":2},{"id":2},{"id":2}]
$[?(false)] [1, 3, "nice", true, null, false, {}, [], -1, 0, ""] none []
$[?(@..child)] [{"key": [{"child": 1}, {"child": 2}]}, {"key": [{"child": 2}]}, {"key": [{}]}, {"key": [{"something": 42}]}, {}] none [{"key":[{"child":1},{"child":2}]},{"key":[{"child":2}]}]
$[?(null)] [1, 3, "nice", true, null, false, {}, [], -1, 0, ""] none []
$[?(true)] [1, 3, "nice", true, null, false, {}, [], -1, 0, ""] none [1,3,"nice",true,null,false,{},[],-1,0,""]
$[?@.key==42] [ {"key": 0}, {"key": 42}, {"key": -1}, {"key": 1}, {"key": 41}, {"key": 43}, {"key": 42.0001}, {"key": 41.9999}, {"key": 100}, {"key": "some"}, {"key": "42"}, {"key": null}, {"key": 420}, {"key": ""}, {"key": {}}, {"key": []}, {"key": [42]}, {"key": {"key": 42}}, {"key": {"some": 42}}, {"some": "value"} ] none null
$[?(@.key)] [ { "some": "some value" }, { "key": true }, { "key": false }, { "key": null }, { "key": "value" }, { "key": "" }, { "key": 0 }, { "key": 1 }, { "key": -1 }, { "key": 42 }, { "key": {} }, { "key": [] } ] none [{"key":true},{"key":"value"},{"key":1},{"key":-1},{"key":42}]

Misc Test

match selector data consensus actual
`` {"a": 42, "": 21} nil null
$.data.sum() {"data": [1,2,3,4]} none null
$(key,more) {"key": 1, "some": 2, "more": 3} nil null
$.. [{"a": {"b": "c"}}, [0, 1]] none [[{"a":{"b":"c"}},[0,1]],{"a":{"b":"c"}},{"b":"c"},"c",[0,1],0,1]
$.key.. {"some key": "value", "key": {"complex": "string", "primitives": [0, 1]}} none [{"complex":"string","primitives":[0,1]},[0,1],0,1,"string"]
$ { "key": "value", "another key": { "complex": [ "a", 1 ] } } {"another key":{"complex":["a",1]},"key":"value"} {"another key":{"complex":["a",1]},"key":"value"}
$ 42 42 42
$ false false false
$ true true true
$[(@.length-1)] ["first", "second", "third", "forth", "fifth"] nil "fifth"

Union Test

match selector data consensus actual
$[0,1] ["first", "second", "third"] ["first","second"] ["first","second"]
$[0,0] ["a"] ["a","a"] ["a","a"]
$['a','a'] {"a":1} [1,1] [1,1]
$[?(@.key<3),?(@.key>6)] [{"key": 1}, {"key": 8}, {"key": 3}, {"key": 10}, {"key": 7}, {"key": 2}, {"key": 6}, {"key": 4}] none []
$['key','another'] { "key": "value", "another": "entry" } ["value","entry"] ["value","entry"]
$['missing','key'] { "key": "value", "another": "entry" } ["value"] ["value"]
$[:]['c','d'] [{"c":"cc1","d":"dd1","e":"ee1"},{"c":"cc2","d":"dd2","e":"ee2"}] ["cc1","dd1","cc2","dd2"] [["cc1","dd1"],["cc2","dd2"]]
$[0]['c','d'] [{"c":"cc1","d":"dd1","e":"ee1"},{"c":"cc2","d":"dd2","e":"ee2"}] ["cc1","dd1"] ["cc1","dd1"]
$.*['c','d'] [{"c":"cc1","d":"dd1","e":"ee1"},{"c":"cc2","d":"dd2","e":"ee2"}] ["cc1","dd1","cc2","dd2"] [["cc1","dd1"],["cc2","dd2"]]
$..['c','d'] [{"c":"cc1","d":"dd1","e":"ee1"}, {"c": "cc2", "child": {"d": "dd2"}}, {"c": "cc3"}, {"d": "dd4"}, {"child": {"c": "cc5"}}] none ["cc1","dd1","cc2","dd2","cc3","dd4","cc5"]
$[4,1] [1,2,3,4,5] [5,2] [5,2]
$.*[0,:5] { "a": [ "string", null, true ], "b": [ false, "string", 5.4 ] } none null
$[1:3,4] [1,2,3,4,5] none null
$[ 0 , 1 ] ["first", "second", "third"] ["first","second"] ["first","second"]
$[*,1] ["first", "second", "third", "forth", "fifth"] nil null