Search code examples
rdfjson-ld

Does @id in JSON-LD need to be globally unique?


Question

Is it necessary for a provider of JSON-LD to make sure that the @id of a node is always globally unique or is it only necessary for @id to be unique inside a JSON-LD document?

Example

Let's say we have two different articles at different web sites which are both licensed under CC-BY-SA 4.0. They use https://schema.org/ with JSON-LD to describe their metadata. One article uses the URI http://creativecommons.org/licenses/by-sa/4.0/ and the other https://creativecommons.org/licenses/by-sa/4.0/deed.en as @id for the property license

JSON-LD of article A

{
  "@context": "https://schema.org/",
  "@type": "Article",
  "name": "A"
  "url": "https://a.com/article",
  "license": {
    "@id": "http://creativecommons.org/licenses/by-sa/4.0/"
  }
}

JSON-LD of article B

{
  "@context": "https://schema.org/",
  "@type": "Article",
  "name": "B"
  "url": "https://b.com/article",
  "license": {
    "@id": "https://creativecommons.org/licenses/by-sa/4.0/deed.en"
  }
}

In the above example when I check both license URIs with the schema.org validator I get

{
  "@id": "https://creativecommons.org/licenses/by-sa/4.0/deed.id"
}

Is the license property of both articles referring to the same or to different JSON-LD nodes? Is it the job of the consumer or the provider of the metadata to resolve the different URIs to the globally unique identifier https://creativecommons.org/licenses/by-sa/4.0/deed.id?

(I can assume that it is a good practice for both the provider and the consumer to try to resolve different URIs to a globally unique one. However I am interested to know what the spec is saying about the above example.)


Solution

  • Is the license property of both articles referring to the same or to different JSON-LD nodes?

    They are referring to different nodes.

    The fact that Schema.org’s Validator displays https://creativecommons.org/licenses/by-sa/4.0/deed.id as top-level item on both of these pages can be confusing, but it has no relevance. This is the Indonesian version of the license (it has the language code id, so it has nothing to do with "identifier"), which happens to be the first one listed in the HTML.

    The extracted RDF correctly says that this Indonesian version is a translation (frbr:translationOf) of http://creativecommons.org/licenses/by-sa/4.0/.

    Is it the job of the consumer or the provider of the metadata to resolve the different URIs to the globally unique identifier […]?

    It has to be the job of the data provider to specify exactly the right/intended IRI. After all, only they know what they want to convey.

    These IRIs don’t have to be resolvable at all. It’s a good practice, but not required, and also not always possible (e.g., when using URI schemes like urn, tel, tag, etc.). And a consumer of the RDF is never required to try to resolve these IRIs.