RE: json-ld-api type fidelity in RDF roundtripping

On Thursday, April 04, 2013 4:18 PM, Andy Seaborne wrote:
 
> I don't see that you should separate them:
> 
> RFC 4627:
> [[
> JSON's design goals were for it to be minimal, portable, textual, and
> a subset of JavaScript.
> ]]
> (and reference to ECMAscript)
> 
> so while JSON syntax may allow long numbers, there is implicitly a
> limit
> to the range/precision of floating point doubles.
> 
> It would be better to note that xsd:int is safe but xsd:integer is not
> for javascript.

OK, I've added a sentence [1]. The relevant paragraph now looks as follows:

[[[
When JSON-native numbers, are converted to RDF, lossless data round-tripping
can not be guaranteed as rounding errors might occur. When converting RDF to
JSON-LD, similar rounding errors might occur. Furthermore, the datatype or
the lexical representation might be lost. An xsd:double with a value of 2.0
will, e.g., result in an xsd:integer with a value of 2 in canonical lexical
form when converted from RDF to JSON-LD and back to RDF. It is important to
highlight that in practice it might be impossible to losslessly convert an
xsd:integer to a number because its value space is not limited. While the
JSON specification [RFC4627] does not limit the value space of numbers
either, concrete implementations do have a limited value space.

To ensure lossless round-tripping the Converting from RDF algorithm
specifies an use native types flag...
]]]

I didn't mention xsd:int to not make it too confusing.



[1]
https://github.com/json-ld/json-ld.org/commit/111f7106801fd4a4e1367f8d6bd7ea
94671e08b4



--
Markus Lanthaler
@markuslanthaler

Received on Thursday, 4 April 2013 15:21:59 UTC