1 of 11

Problems with JSON-LD and Content Based Addressing

bserdar@cloudprivacylabs.com

2 of 11

JSON-LD for Layered Schemas: The Bad

  • JSON-LD is not "namespaces for JSON":
    • If local(a)=local(b), then a=b iff ns(a)=ns(b) (namespace)
    • In JSON-LD, it is possible to have key(a)=key(b) but a≠b
      • Not a namespace, but key mapping

3 of 11

JSON-LD for Layered Schemas: The Bad

  • @context does not enforce structure
    • @context is sets of mappings. The mapping is selected by @type.
  • Layered schema example:
    • Polymorphism: An attribute node can be of type (Attribute, Object), etc. There is no way to specify that an Object is also an Attribute
    • Type inference: if a JSON object contains "elements", it is an Array

4 of 11

JSON-LD for Layered Schemas: The Bad

  • @context does not define semantics, only terminology. No versioning mechanism
    • Does the meaning evolve with evolving terminology?
    • Or is the meaning fixed?

5 of 11

JSON-LD for Layered Schemas: The Bad

  • JSON-LD is extremely difficult to understand and debug.
    • Only after expanding the context
  • Readability ≠ Clarity
  • JSON data is usually self-explanatory without processing.
  • Go Motto: Clear is better than clever (https://dave.cheney.net/2019/07/09/clear-is-better-than-clever)

6 of 11

JSON-LD for Layered Schemas: The Good

  • Expanded JSON-LD is JSON
  • Self-describing nodes is a good idea (for layered schemas):

{ "@id": "nodeId" }

{ "@value": "someValue" }

7 of 11

Content Based Addressing: Digests

Digestability

  • Normalized representation
  • Self-contained

Is normalized representation really necessary?

8 of 11

Content Based Addressing: Docker registries

Client

Registry

sha256:12345...

Manifest.json

sha256:abcd...

sha256:def12...

Digest computed on wire data (blob), including for JSON (no normalization)

9 of 11

{

"id": "https://example.org/objA/schema",

"schema": "https://example.org/objABase",

"overlays": [

"https://example.org/ovl1",

"https://example.org/ovl2"

]

}

Addressing Schemas: Weak References

{

"id": "https://example/objABase"

}

{

"id": "https://example/ovl1_1"

}

https://example.org/objA/schema

{

"id": "https://example.org/objA/schema",

"schema": "https://example.org/objABase",

"overlays": [

"https://example.org/ovl1",

"https://example.org/ovl2"

]

}

{

"id": "https://example.org/objA/schema",

"schema": "https://example.org/objABase",

"overlays": [

"https://example.org/ovl1",

"https://example.org/ovl2"

]

}

{

"id": "https://example/objABase"

}

{

"id": "https://example/ovl1"

}

{

"id": "https://example/ovl2"

}

{

"id": "https://example/ovl2"

}

10 of 11

Addressing Schemas: Strong References

https://example.org/objA/schema

sha256:aaabbbccc...

{

"id": "https://example.org/objA/schema",

"schema": "sha256:12345...",

"overlays": [

"sha256:abcdef...",

"sha256:a1b2c3..."

]

}

{

"id": "https://example/objABase"

}

{

"id": "https://example/ovl1"

}

{

"id": "https://example/ovl2"

}

sha256:12345...

sha256:abcdef...

sha256:a1b2c3...

sha256:aaabbbccc...

11 of 11

Addressing Schemas: Weak References/Strong Mapping

https://example.org/objA/schema

{

"id": "https://example.org/objA/schema",

"schema": "https://example.org/objABase",

"overlays": [

"https://example.org/ovl1",

"https://example.org/ovl2"

],

"bundle": {

"https://example.org/ovl1": "sha256:1234…",

"https://example.org/ovl2": "sha256:abcdef…"

]

}