-
-
Notifications
You must be signed in to change notification settings - Fork 268
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
Clarification of meaning of Null #584
Comments
@GEricson Do you have a citation for this? |
@GEricson per the introduction of RFC 8259:
Section 3: Values defines the JSON makes a distinction between a value of An empty string is definitely a value in JSON. It can even be used as the name of a property (although this is generally ill-advised). |
Also to elaborate, JSON isn't a programming language, it's a data format; and the purpose of the Data Model is to describe the complete, mathematical set of values that can be expressed by a JSON document. |
@GEricson checking back in on whether you have a citation in support of your assertion, or a counter-example showing that my citation of RFC 8259 is incorrectly interpreted. If we don't hear back from you in the next week, I'll close this out as answered. |
It's been another week with no response, for a total of two weeks of quiet. Closing. |
@handrews and @awwright : Sorry for not responding sooner. I have not been actively monitoring. I agree that RFC8259 defines What needs to be clarified is that As a normative reference, the most comprehensive source for modeling is the Unified Modeling Language (UML), also not a programming language. UML defines |
Are you saying we shouldn't be able to distinguise between empty string and null? |
@Relequestual the empty string is definitely not null. It's a string that contains 0 characters. @GEricson it's true that the absence of a valid implies null in many languages, like .Net, however this is JSON. In JSON the absence of a key is a distinctly different thing than the presence of the key with a value of I dealt with this in Manatee.Json #56 and left some notes of my experience. In short, I found that I needed to track .Net |
@Relequestual It certainly is true that many clients want to distinguish between an empty string and a null. |
@GEricson RFC 8259 explicitly states that null is a type
This is not up for debate. It could not possibly be more clear. Philosophical questions about whether this is the correct conceptual model are irrelevant- it is unambiguously, objectively, and explicitly defined by an RFC that is not just a proposed standard but an actual, ratified standard (green bar at the top). @gregsdennis is also correct that |
Yeah, for our purposes, we've adopted a certain definition, which may or may not be the same definition in other standards or programming languages.
"null" is also the name of a type, a set of values. The "null" type has one item in the set: PHP works the same way, though it differentiates the value >>> gettype(null)
=> "NULL"
>>> gettype(false)
=> "boolean"
>>> gettype("")
=> "string"
>>> gettype(0)
=> "integer" I speculate this might be some confusion with the C concept of NULL, which is a specific location in memory (usually 0 because it's falsy, but sometimes other locations depending on system architecture); C confusingly also has the null byte, which signifies the last byte of nul-terminated strings. JSON has nothing in common with these C concepts. |
Clause "4.2.1 Instance Data Model" describes
null
as one of six primitive type. This is not correct. Insteadnull
is an indicator for the absence of a value. This can apply to elements of any of the remaining five types, each of which specify an allowable range of values, including the possibility of no value. If the schema allows an element to have no value, then the element indicate that it isnull
. An empty string""
, is equivalent to indicatingnull
since in both cases, the element has no value.The text was updated successfully, but these errors were encountered: