Skip to content

Latest commit

 

History

History

README.md

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