w3c / json-ld-cbor

JSON-LD 1.1 in CBOR Note
https://w3c.github.io/json-ld-cbor/
Other
7 stars 6 forks source link

Round-tripping #8

Open pchampin opened 4 years ago

pchampin commented 4 years ago

The current proposal raises some questions about round-tripping, as pointed out in #7.

Currently, both 42 (in JSON) and { "@value": "42", "@type": "http://www.w3.org/2001/XMLSchema#integer"} are encoded identically in CBOR, using a native integer representation (major type 0). Parsing it back to JSON, we transform that native integer into a JSON number 42.

Semantically, both forms are equivalent for JSON-LD. But this means that CBOR would not preserve the expanded-ness of a JSON-LD document in the expanded form.

Is that a problem? I would tend to answer "no". Anyway, it will be further (in §4) suggested to first compact the JSON-LD document into a CBOR-friendly context, to get an even smaller representation.