-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optional root ($
) selector
#8
Comments
I disagree with this proposal. The If individual implementations wish to add support for omitting this character, they can do so without being out of compliance with the spec. |
I used to think this was a good idea, but have since changed my mind, and now share gregsdennis's view. As gregsdennis noted, there are natural extensions to the expression syntax that benefit from being able to base the expression at either the root ( |
Perhaps we should discuss:
It depends. For example, if the spec requires an implementation to return an error if an invalid selector is provided, then implementations wouldn't be able to add this support without becoming non-compliant. The alternative is to make the spec somehow more permissive. For example, we could say that if an invalid selector is provided, then an implementation MAY return an error. My concern with a more permissive approach would be the difficulty of testing that for compliance. |
This was my point in saying it.
Actually, you need to invert the inflection: say that the implementation SHOULD return an error. Leave it at that. This opens the door for optional support of additional syntaxes without explicitly stating it. SHOULD is strong enough that an implementor should think twice before deciding against the requirement, but allows them to still claim compliance if they choose not to. If you want to take it further, the spec could state that the default behavior of the implementation MUST be per spec, but it could have an option or switch that enables extended support.
JSON Schema is quite permissive and has a very extensive test suite. Test what the spec requires. Maybe have optional tests for common permissive cases, or let implementations independently test their optional support. |
As an added note here, I've been looking into JMESPath, and it loos like they've opted to drop the "start path"
|
Interesting. Can they do something semantically equivalent by leaving out the |
hmm ... so equivalent to
would then be
|
That looks quite confusing, in my opinion. If I omit I would prefer to keep |
JMESPath as defined in JMESPath Specification doesn't have a symbol for the root value, there is no counterpart to '$', so it would be more accurate to say that they drop the '@.' from their syntax, where
or
(However, I think the grammar does allow
There were proposals to introduce lexical scoping in JMESPath, see James James Saryerwinnie's original proposal and Michael Dowling's sugestion. These proposals would e.g. support binding the value of Some implementations of JMESPath extend the syntax to support the See also #76, which compares the meaning of "current node" in JSONPath, JMESPath, and XPath 3.1. |
The equivalent JMESPath expression would be
or
|
Closed in #115 |
What was the resolution? Did we decide to require |
A number of implementations support implicit root selector (e.g.
key
instead of$.key
).Proposal
The standard should support optional root selector.
It should be supported since it is widely accepted and also a handy shortform (which I expect to be frequently used).
As an example, we should take into account that this behavior is supported by JavaScript jsonpath and jsonpath-plus that counts for a total of ~800000 weekly downloads and ~900 dependents on npm. Furthermore this is supported by Goessner implementation too.
For the sake of simplicity a path starting with
$
should be defined as "canonical form" / "normal form" on the specification.Therefore, the following:
might be rephrased as:
As a consequence of this feature (for consistency reasons)
["key"]
and[0]
should be supported as well.We also should take a decision about
.key
, which is supported by few popular implementations.The text was updated successfully, but these errors were encountered: