json-ld-api icon indicating copy to clipboard operation
json-ld-api copied to clipboard

blind spot in RDF to object conversion

Open pchampin opened this issue 2 years ago • 4 comments

I believe that the RDF to object conversion, step 2.3.4, has a blind spot. This is in the case useNativeTypes is used:

if the datatype IRI of value equals xsd:integer or xsd:double and its lexical form is a valid xsd:integer or xsd:double according [XMLSCHEMA11-2], set converted value to the result of converting the lexical form to a JSON number.

The problem is: some valid literals of these datatypes may fail to convert to JSON numbers, e.g. "+INF"^^xsd:double, or very large integers.

The spec is currently silent about that. We should either specify that an error must be raised, or that useNativeType should be ignored in that case, and a regular value object should be generated. I personally prefer the 2nd option.

pchampin avatar Dec 13 '22 09:12 pchampin

We should probably be using logic from JCS for dividing these different forms.

gkellogg avatar Dec 13 '22 17:12 gkellogg

Sorry, what do you mean by "JCS"?

pchampin avatar Dec 16 '22 14:12 pchampin

JSON Canonicalization, which we use when serializing JSON literals

gkellogg avatar Dec 16 '22 18:12 gkellogg

JSON Canonicalization, which we use when serializing JSON literals

ah... thanks

JCS Appendix D. Dealing with Big Numbers says

numbers that do not have a natural place in the current JSON ecosystem MUST be wrapped using the JSON string type.

This is aligned with my suggestion above: whenever a literal can not be mapped to a JSON number, ignore useNativeType and keep it as a value object with explicit @value (as a string) and @type.

pchampin avatar Jan 09 '23 15:01 pchampin