ojg: Results do not match other implementations
The following queries provide results that do not match those of other implementations of JSONPath (compare https://cburgmer.github.io/json-path-comparison/):
-
$[1:3]Input:[ "first", "second", "third", "forth", "fifth" ]Expected output:
["second", "third"]Actual output:
[ "second", "third", "forth" ] -
$[0:5]Input:[ "first", "second", "third", "forth", "fifth" ]Expected output:
["first", "second", "third", "forth", "fifth"]Actual output: NOT_FOUND
-
$[1:10]Input:[ "first", "second", "third" ]Expected output:
["second", "third"]Actual output: NOT_FOUND
-
$[-4:-4]Input:[ 2, "a", 4, 5, 100, "nice" ]Expected output:
[]Actual output:
[ 4 ] -
$[-4:-3]Input:[ 2, "a", 4, 5, 100, "nice" ]Expected output:
[4]Actual output:
[ 4, 5 ] -
$[-4:2]Input:[ 2, "a", 4, 5, 100, "nice" ]Expected output:
[]Actual output:
[ 4 ] -
$[-4:3]Input:[ 2, "a", 4, 5, 100, "nice" ]Expected output:
[4]Actual output:
[ 4, 5 ] -
$[:2]Input:[ "first", "second", "third", "forth", "fifth" ]Expected output:
["first", "second"]Actual output:
[ "first", "second", "third" ] -
$[-4:]Input:[ "first", "second", "third" ]Expected output:
["first", "second", "third"]Actual output: NOT_FOUND
-
$[0:3:1]Input:[ "first", "second", "third", "forth", "fifth" ]Expected output:
["first", "second", "third"]Actual output:
[ "first", "second", "third", "forth" ] -
$[0:4:2]Input:[ "first", "second", "third", "forth", "fifth" ]Expected output:
["first", "third"]Actual output:
[ "first", "third", "fifth" ] -
$[]Input:{ "": 42, "''": 123, "\"\"": 222 }Expected output:
NOT_SUPPORTEDActual output:
[ { "": 42, "\"\"": 222, "''": 123 } ] -
$..[1].keyInput:{ "k": [ { "key": "some value" }, { "key": 42 } ], "kk": [ [ { "key": 100 }, { "key": 200 }, { "key": 300 } ], [ { "key": 400 }, { "key": 500 }, { "key": 600 } ] ], "key": [ 0, 1 ] }Expected output (in any order as no consensus on ordering exists):
[200, 42, 500]Actual output:
[ 42 ] -
$..keyInput:{ "object": { "key": "value", "array": [ { "key": "something" }, { "key": { "key": "russian dolls" } } ] }, "key": "top" }Expected output (in any order as no consensus on ordering exists):
["russian dolls", "something", "top", "value", {"key": "russian dolls"}]Actual output:
[ "something", "top", "value", { "key": "russian dolls" } ] -
$.store..priceInput:{ "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 } } }Expected output (in any order as no consensus on ordering exists):
[12.99, 19.95, 22.99, 8.95, 8.99]Actual output:
[ 19.95 ] -
$[?(1==1)]Input:[ 1, 3, "nice", true, null, false, {}, [], -1, 0, "" ]Error:
unexpected character ']' at 1:40
For reference, the output was generated by the program in https://github.com/cburgmer/json-path-comparison/tree/master/implementations/Golang_github.com-ohler55-ojg.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 25 (17 by maintainers)
Yes, happy to close.
Yes and no. I believe it’s complex 😃 Currently the comparison table is nearly overflowing my monitor, and such a big table is difficult to read either way. I did contemplate allowing a denser view by default via hiding some of the less “compliant” implementations, but that opens up other questions:
Awesome. I hope we can help our users make better decisions when adopting a certain implementation.
I’ll submit a merge request for the update along with a few other changes to main.go and go.mod. You can choose to ignore of merge. I won’t take offence in either case.
I think I have the slices covered. I had the end being inclusive and the consensus was for exclusive. That covered a majority of the differences. I’ll release and take another look.
BTW, the headers are readable now.
I think the latest in the consensus branch should pass all but the key with a dash in it but I don’t plan on changing that one.
Thanks. I’ll update Oj to more closely follow the consensus.
As a side note, on Safari the header labels on your table all blended together making it unreadable for the golang entries.