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

Validity of numbers #378

Closed glyn closed 1 year ago

glyn commented 1 year ago

The ABNF number is not currently subject to the I-JSON range restriction that applies to array indices and array slice parameters, but I don't see why it shouldn't be.

cabo commented 1 year ago

I don't understand -- the grammar cannot express this restriction. Indices and slice parameters are integers, not numbers, BTW.

glyn commented 1 year ago

I was thinking of the integer subset of number. It seems strange to have to cope with arbitrary precision integers there, but not for array indices and slices.

glyn commented 1 year ago

As for the grammar expressing the restriction, this is a question of validity rather than well-formedness.

cabo commented 1 year ago

Ah, so this would be a text fix.

glyn commented 1 year ago

Ah, so this would be a text fix.

Indeed. Sorry for the ABNF red herring. I was trying to be precise about which "number" I was talking about.

glyn commented 1 year ago

I guess we'll have to worry about decimal as well as integers in number, for consistency. I wonder if there's a suitable precedent like the I-JSON range?

cabo commented 1 year ago

Hmm, $[?1.000000000000000000000000000001 == 1.000000000000000000000000000002] is not really discussed in the unnumbered (argh) section "comparisons". (There is text for <.)

glyn commented 1 year ago

How about this text?

When any path on either side of a comparison results in a nodelist consisting of a single node, each such path is replaced by the value of its node and then:

  • a comparison using the operator == yields true if and only if the comparison is between:
    • equal primitive values,
glyn commented 1 year ago

(and in case anyone thinks we could get away with comparing the string forms of the numbers, remember scientific notation 1e2 == 100.)

glyn commented 1 year ago

Oh, I see now. We should mention the I-JSON restrictions for numbers, in the comparison section. That seems like a reasonable way to fix this issue.