Re: XSD datatypes in JSON-LD (was: Re: Use of XSD namespace in RDF recommendations)

On 5 Sep 2012, at 11:20, Markus Lanthaler wrote:
>> Why not convert "5"^^xsd:double to a JSON-native 5.0? This would allow
>> round-tripping, and no useNativeTypes flag is necessary.
> 
> The problem is that JSON parsera automatically "normalize" a 5.0 to 5 during
> parsing. Since we reuse existing JSON parsers, there's no way for us to
> check whether there was a .0 or not.

TIL that every number is a double in JS.

I guess it's not possible to round-trip idiomatic RDF numbers through idiomatic JSON. Oh well.

What is the justification then for treating the JSON literal 5 as "5"^^xsd:integer in toRDF, rather than as "5"^^xsd:double? The latter seems to be the accurate translation.

Another issue I suppose is that xsd:double contains the values NaN, INF and -INF, which are not valid as JSON numbers and hence cannot be round-tripped if native JSON numbers are used.

Best,
Richard

Received on Wednesday, 5 September 2012 10:51:19 UTC