w3c / json-ld-syntax

JSON-LD 1.1 Specification
https://w3c.github.io/json-ld-syntax/
Other
112 stars 22 forks source link

Use of null value with JSON literals #258

Closed azaroth42 closed 5 years ago

azaroth42 commented 5 years ago

Typically the null value removes the property or resets a context. However JSON literals capture any legal JSON value, which includes null.

Thus there is ambiguity currently as to the expected result of a property with a JSON literal typed value where the @value is null. Current implementations are inconsistent between compact and expanded form, and thus there is missing text in the algorithm to preserve null when the type is @json.

{
  "@context": {
    "@version": 1.1,
    "property": {"@id": "rdfs:label", "@type": "@json"}
  },
  "property": null
}
azaroth42 commented 5 years ago

RESOLUTION: WG believes that it is least surprising to process null as a JSON literal in this case, and not to remove the property in the internal representation, and thus the null should be preserved.

iherman commented 5 years ago

This issue was discussed in a meeting.

gkellogg commented 5 years ago

Actually, I don't think there's anything more to say in the syntax document. It's handled in w3c/json-ld-api#155. Happy to add some extra wording to the syntax document if people think it necessary.

azaroth42 commented 5 years ago

I think there should be a non-normative note in syntax, in 4.2.2, as there is a potential expectation that nulls will not be processed, as with other cases.

iddan commented 5 years ago

Why is null not converted to rdf:nil?

rubensworks commented 5 years ago

Why is null not converted to rdf:nil?

rdf:nil is not equivalent to null. rdf:nil is used to indicate the end of an RDF list. The spec says the following:

The resource rdf:nil is an instance of rdf:List that can be used to represent an empty list or other list-like structure.

iddan commented 5 years ago

Oh, my bad. Thank you.

azaroth42 commented 5 years ago

Also, this is specifically about JSON literals, where the JSON values are intentionally left as JSON rather than mapped into RDF.