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

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

Make all undesirable comparisons yield false #230

Closed glyn closed 2 years ago

glyn commented 2 years ago

And:

(Reviewers may like to view this rendered version.)

The options under consideration in issue 212 were:

  1. The current draft as of 2022-07-22.
  2. The option of making <, >, <=, and >= false when not comparing two numbers.
  3. The NaB proposal.
  4. The NaB proposal, but with left-to-right evaluation and short-circuiting.
  5. The option of forcing a total order among all values, like Erlang does.
  6. The option of not selecting the current item if any type-mismatched comparisons occur anywhere in the expression.

This is option 2 with string comparisons.

Fixes https://github.com/ietf-wg-jsonpath/draft-ietf-jsonpath-base/issues/212

cabo commented 2 years ago

On 28. Jul 2022, at 00:19, Greg Dennis @.***> wrote:

This brings up an interesting point. JSON requires that UTF-16 characters

(Do you mean beyond-BMP characters?)

be encoded in \uxxxx pairs.

You do not need to encode beyond-BMP characters, but if you do, you indeed go through UTF-16 surrogate pairs.

Is the encoding sufficient to determine correct ordering (i.e. does sorting by the encoded strings yield the same result as sorting the unencoded characters)?

No, and that is true of other backslash-encoded characters, too.

You can sort by Unicode Scalar Values. You can also sort by UTF-32 code units (obviously) and by UTF-8 code units (a.k.a. bytes) — UTF-8 was careful to preserve sorting order.

Grüße, Carsten

glyn commented 2 years ago

I think there may be room for further fine-tuning but at this point I'd like to merge this and get a nice editors' draft that we can read end-to-end.

Merging. We can fine-tune in a follow-on PR.