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

Context-based optimization #4

Open vcharpenay opened 4 years ago

vcharpenay commented 4 years ago

Some recurrent patterns within a JSON-LD documents could be summarized as a context entry and serialized in a more compact way using a local context.

E.g.

{
  "@graph": [
    { "p": { "@value": "2", "@type": "xsd:unsignedInt" } },
    { "p": { "@value": "4", "@type": "xsd:unsignedInt" } }
  ]
}

is equivalent to:

{
  "@context": {
    "p": { "@type": "xsd:unsignedInt" }
  },
  "@graph": [
    { "p": 2 },
    { "p": 4 }
  ]
}
davidlehn commented 4 years ago

Perhaps transformations like this are out of scope for basic CBOR serialization? They produce the same semantic data, but a JSON to "optimized" CBOR to JSON round trip would not result in equivalent JSON structures. I'm not sure where these algorithms should be developed. Maybe something to add to the best practices doc. Some transformations may be serialization specific too. In any case, I imagine using these should be optional.

pchampin commented 4 years ago

I think this note can cover two kinds of thing:

Those are indeed two different problems, which should be presented separately, but I think both are in scope. Note that #1 also relates to the second category.

msporny commented 4 years ago

I wrote some stuff down about context-based optimization experiments we've done over the past couple of years at Digital Bazaar: https://github.com/w3c/json-ld-cbor/issues/6