-
Notifications
You must be signed in to change notification settings - Fork 190
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
Distinct values for undefined and null #177
base: master
Are you sure you want to change the base?
Conversation
@ktoso @sirthias I know it's been a while, but with https://tools.ietf.org/html/rfc7396 out, it's becoming more important to distinguish between values which do not appear in JSON and values which are Thank you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contrib; I realize this comes late however still wanted to review before we cut the next release.
The example you use in the doc here seems to be an interpretation of the JSON Patch spec. It however does not talk about the undefined
value, but simply uses it to mean "key not included in the patch request". See section 4 https://tools.ietf.org/html/rfc6902#section-4
On the other hand, undefined
is not really part of JSON at all (sic), as the JSON spec defines explicitly:
A JSON value can be an object, array, number, string, true, false, or null. [ ECMA-404, section 5 http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf ]
So, undefined
is not a valid JSON value. JSON, even though it is valid in javascript. So by adding specil handling for undefined here we actually introduce 4 states, without being able to distinguish between explicitly set to a value called "undefined" and not-being-set-at-all.
As the use-case shown seems to indicate the use is very much in line with JSON Patch, I'd rather err on not including non-JSON in this JSON library.
If you think there's some strong line of argument or need to do so regardless please show some example that would showcase that. Thanks again for the PR and patience (we know we're pretty slow on maintaining this one, however we see it pretty much as "feature complete", in it's own, minimal, feature-set)
Thanks for the feedback, @ktoso . |
That depends what the client library decides to do with this value, we can't really assume that; though if it would send
You mean the |
….minor version error.
…ript but not JSON itself.
@ktoso I have removed the support for
for my
I'm not that familiar with mima, so I'm not sure what the issue is here... |
Projects I have been working on need to know whether missing values are really null, or whether they were undefined (or not sent at all). Scala options can't handle that, so I've created a Tription (triple option) which makes a distinction between null and undefined.
This patch is my original work and that I license the work to the spray-json project under the project’s open source license.