-
Notifications
You must be signed in to change notification settings - Fork 26
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
Should $[?(@.key)]
distinguish between undefined and null in Proposal A?
#53
Comments
I think that should not be language-dependent. JSON is a string; the implementation is responsible for correct parsing, and any language is able to implement stream parsing of JSON. But I totally agree with rejecting only non-existing keys. And in fact, that's exactly what intuitively follows from Goessner's proposal:
|
I'm not concerned that some features allow pointless possibilities, unless they are likely to mislead users which I don't think is the case here. |
I'm interested whether there really is a use case for distinguishing
However
I believe we will find more examples for either bucket. |
I don't read anything specific from Goessner's proposal. He does not given an example on |
Distinguishing between a
|
I've seen at least one implementation of JSONPath implement a specific function that checks for the existence of the key. I just don't remember where I saw this. |
I took this approach in warpath, @.key means key exists at current node, there are a couple of functions supported that could be used to check the value of key, for example, is_nil, is_boolean etc. |
I think the behaviour has to be as much intuitive as possible and having that in mind I'd treat the expression
So for me the only uncertain situation here is a false value, and the uncertainty comes from the fact that the result of |
It seems there is no consensus whatsoever on "filter with value". I've tried catching a variety of types in
https://cburgmer.github.io/json-path-comparison/results/filter_expression_with_value.html, and you can see a mix of responses, with or without
My reasoning to reject only the undefined key case for Proposal A was that there is no other way to implement that with the current set in JSONPath. So this would give me the most flexibility.
However this leads to query
$[?(@)]
becoming completely pointless, because all elements in an array are defined.Also, I't unclear whether most languages even let you distinguish between a key being present or with value
null
.The text was updated successfully, but these errors were encountered: