ietf-wg-jsonpath / draft-ietf-jsonpath-base

Development of a JSONPath internet draft
https://ietf-wg-jsonpath.github.io/draft-ietf-jsonpath-base/
Other
58 stars 20 forks source link

Wrong result paths in examples #398

Closed mcatanzariti closed 1 year ago

mcatanzariti commented 1 year ago

Hi,

There are wrong result paths in some examples:

§2.5.5 Filter selector $.a[?(@.b == $.x)] should have result paths:

$['a'][0]
$['a'][1]
$['a'][2]
$['a'][3]
$['a'][4]
$['a'][5]

§2.7.2 Descendant Segment $.a..[0, 1] should have result paths:

$['a'][0]
$['a'][1]
$['a'][2][0]
$['a'][2][1]
glyn commented 1 year ago

Please could you describe how you arrived at those results from the spec? That way, even if the results are incorrect, we can see if there are parts of the spec which are easily misinterpreted.

On Sat, 18 Feb 2023, 00:29 Michaël Catanzariti, @.***> wrote:

Hi,

There are errors in some result paths examples:

§2.5.5 Filter selector @.*** == $.x)] should have result paths:

$['a'][0]

$['a'][1]

$['a'][2]

$['a'][3]

$['a'][4]

$['a'][5]

§2.7.2 Descendant Segment $.a..[0, 1] should have result paths:

$['a'][0]

$['a'][1]

$['a'][2][0]

$['a'][2][1]

— Reply to this email directly, view it on GitHub https://github.com/ietf-wg-jsonpath/draft-ietf-jsonpath-base/issues/398, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAXF2PKUVSBTAHJLYVJTRDWYAJYLANCNFSM6AAAAAAVAAHCJY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

mcatanzariti commented 1 year ago

I'm actually porting JSONPath to CBORPath based on the JSONPath specs: https://github.com/dahomey-technologies/cborpath-rs

And I found the errors by writing unit tests based on the examples in the JSONPath specs.

mcatanzariti commented 1 year ago

For the first error (2.5.5), you can see, by reading the example table, that there is a mismatch between the number of nodes:

3
5
1
2
4
6

and the number of paths:

$['a'][0]
$['a'][1]
$['a'][2]
$['a'][3]
$['a'][4]

Then by analyzing the problem, it becomes obvious that $['a'][5] is missing.

Sadly, I could not reproduce the problem in any JSONPath online because paths with no values within filters are not well supported...

mcatanzariti commented 1 year ago

For the second error (2.7.2), I could reproduce it here:

https://jsonpath.com/

Screenshot_20230218-094204

cabo commented 1 year ago

Thank you! Now PR #399

We definitely need to add checking the examples (not just for ABNF compliance) to the CI.

mcatanzariti commented 1 year ago

Do you already have a reference implementation of the draft in any language ?

glyn commented 1 year ago

I was developing a RI and CTS before I was called upon to spend more time editing the spec. See:

https://github.com/jsonpath-standard/

On Sat, 18 Feb 2023, 14:26 Michaël Catanzariti, @.***> wrote:

Do you already have a reference implementation of the draft in any language ?

— Reply to this email directly, view it on GitHub https://github.com/ietf-wg-jsonpath/draft-ietf-jsonpath-base/issues/398#issuecomment-1435688630, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAXF2NAXKNO6TYOQZYWE33WYDL2XANCNFSM6AAAAAAVAAHCJY . You are receiving this because you commented.Message ID: @.*** com>

mcatanzariti commented 1 year ago

Awesome!

gregsdennis commented 1 year ago

I have JsonPath.Net as part of https://github.com/gregsdennis/json-everything. You can test its latest at https://json-everything.net/json-path.

To my knowledge, this is the only lib that implements the full current doc (aside from a few minor open discussions), including functions.