json-ld/json-ld.org

"Visualized" tab ignores `id` even when `@context` aliases `id` to `@id`; only accepts literal `@id`

Opened this issue · 3 comments

trwnh commented

Given a document such as this for input:

{
  "@context": [
    "https://www.w3.org/ns/did/v1",
    "https://w3id.org/security/multikey/v1",
    "https://w3id.org/security/suites/secp256k1-2019/v1"
  ],
  "alsoKnownAs": [
    "at://atproto.com"
  ],
  "id": "did:plc:ewvi7nxzyoun6zhxrhs64oiz",
  "service": [
    {
      "id": "#atproto_pds",
      "serviceEndpoint": "https://enoki.us-east.host.bsky.network",
      "type": "AtprotoPersonalDataServer"
    }
  ],
  "verificationMethod": [
    {
      "controller": "did:plc:ewvi7nxzyoun6zhxrhs64oiz",
      "id": "did:plc:ewvi7nxzyoun6zhxrhs64oiz#atproto",
      "publicKeyMultibase": "zQ3shunBKsXixLxKtC5qeSG9E4J5RkGN57im31pcTzbNQnm5w",
      "type": "Multikey"
    }
  ]
}

The JSON-LD Playground's "Visualized" tab renders with blank nodes instead of using the actual identifiers.

image

Changing all 3 instances of id to @id seems to fix it.

image

Yeah, I'm not sure what it should do here, but that behavior is poor. This code hasn't been touched probably since it was first added. Patches welcome, but the code base is difficult to work with and waiting on someone (me?) to refactor it to be easier to update.

trwnh commented

I think it should recognize id as an alias of @id right? But I understand if the whole thing needs more work.

The general case is that until you process the data with the contexts you don't know what id maps to or what maps to @id. id to @id is a common convention, but not required. Visualizing the expanded form or N-Quads would be easier, but may be lower level than what people wanted to see. There's plenty of room for improved tooling in this area.