GithubHelp home page GithubHelp logo

Comments (12)

danielaparker avatar danielaparker commented on June 3, 2024 4

Strongly disagree, I think leading zeros should be an error, particularly as they are in JSON proper. There is no benefit to allowing them, they add nothing, except confusion whether this represents octal notation or not.

from json-path-comparison.

danielaparker avatar danielaparker commented on June 3, 2024 2

You could always use your prerogative as owner of this site to say a resounding no! to the consensus on this:-) My own view is that the representation of numbers shouldn't differ from ECMA-404. Moreover, most of the JSONPath implementations lack a formal grammar, so it can be hard to tell whether a "feature" has been intended or merely reflects absent validation. For instance I doubt whether any implementation intended to support octal notation for array indexing, as some have. More likely the unintended consequence of using a general purpose to_integer function.

from json-path-comparison.

glyn avatar glyn commented on June 3, 2024 2

The JSON spec for numbers disallows leading zeroes. I'm tending towards making leading zeroes a syntax error. (This will also allow implementations to add octal support as a strict extension of Proposal A if they choose to.)

from json-path-comparison.

cburgmer avatar cburgmer commented on June 3, 2024 1

Here's the second example: https://cburgmer.github.io/json-path-comparison/results/array_slice_with_step_and_leading_zeros.html
You can see for one there's a consensus, for the other currently not.

That was I think the only motivation to currently not support it. I'll document that. As always, happy to discuss :)

from json-path-comparison.

remorhaz avatar remorhaz commented on June 3, 2024 1

I think that classic octal notation with leading zero is highly confusing for many modern users. I think that there's no reason to forbid leading zeros. My implementation fails to parse them right now, but I tend to consider it a bug.

But maybe it's wise to forbid leading zeros explicitly.

from json-path-comparison.

glyn avatar glyn commented on June 3, 2024

@danielaparker Great point about leading zeroes not being valid in JSON. Case closed?

from json-path-comparison.

cburgmer avatar cburgmer commented on June 3, 2024

If we say we don't support leading zeros for Proposal A, then we would have our first case where we advocate for not supporting something while the consensus offers a result.

from json-path-comparison.

remorhaz avatar remorhaz commented on June 3, 2024

most of the JSONPath implementations lack a formal grammar, so it can be hard to tell whether a "feature" has been intended or merely reflects absent validation

I tend to share this point of view.

I'd like to mention that some implementations allow using JSON object literals. Now let's remember that JSON scalars are also valid JSON documents; so maybe it would be convenient just to delegate JsonPath scalars to JSON spec? I mean, we can just use strict JSON syntax subset for defining JsonPath literals, including:

  • strings/integers in bracket notation;
  • integers in array slices;
  • any valid JSON document as literal in filters.

from json-path-comparison.

danielaparker avatar danielaparker commented on June 3, 2024

@remorhaz Agree that wherever possible a formalization of JSONPath should refer to existing specifications.

from json-path-comparison.

cburgmer avatar cburgmer commented on June 3, 2024

Now let's remember that JSON scalars are also valid JSON documents; so maybe it would be convenient just to delegate JsonPath scalars to JSON spec?

Just to call out a limitation to that suggestion: we would have to separately support strings with single quotes. Some implementations even support arrays of strings with single quotes.

from json-path-comparison.

remorhaz avatar remorhaz commented on June 3, 2024

Dark ages of JsonPath have ruined my beautiful idea, alas. But I still think that we should keep as close to existing JSON spec as possible; something like STRING_KEY ::= JSON_STRING | SINGLE_QUOTED_STRING. And this derives another problem - of extending JSON values, like this: $.foo[?(@.bar=={"a":'b'})]. I mean, the question is: if we allow single-quoted strings in bracket-child, should we forbid them elsewere?

from json-path-comparison.

danielaparker avatar danielaparker commented on June 3, 2024

But I still think that we should keep as close to existing JSON spec as possible; something like STRING_KEY ::= JSON_STRING | SINGLE_QUOTED_STRING.

Agreed.

And this derives another problem - of extending JSON values, like this: $.foo[?(@.bar=={"a":'b'})]. I mean, the question is: if we allow single-quoted strings in bracket-child, should we forbid them elsewhere?

I think so, since implementations will want to use an existing JSON parser for parsing JSON values.

from json-path-comparison.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.