4

Best practices says that

JSON documents may be in the form of a object, or an array of objects. For most purposes, developers need a single entry point, so the JSON SHOULD be in the form of a single top-level object.

This seems to me to be encouraging the idea that the top-level object in a JSON-LD document has some special significance, say that it might be where processing should start. This works fine for RDF-unaware components but, when the JSON-LD document has been converted into RDF, how do I tell which node is the top-level object? Is the RDF-unaware component attaching significance to something that has no semantic footprint?

Some possible solutions I am considering:

  1. Ask the RDF-unaware client to mark the root node for me (e.g. rdf:type my:RootNode)
  2. Find the blank node (subject) that never appears as an object (and hope there is exactly one).
  3. Load the JSON-LD as JSON, and do (1) myself before parsing, hoping that the JSON-LD is always in just the right form.
Bovlb
  • 41
  • 2
  • 4. Analyze [frame](https://w3c.github.io/json-ld-framing/#framing), if it is available. – Stanislav Kralin Feb 12 '20 at 19:38
  • @Stanislav: Thanks for the response. I understand how I can use frame when converting from RDF to JSON-LD to ensure a specific node becomes the root, but I don't see how it helps in the other direction. Am I missing something obvious? – Bovlb Feb 13 '20 at 14:54
  • Well, in case of [matching on @id](https://w3c.github.io/json-ld-framing/#matching-on-id), just take top-level `@id`. – Stanislav Kralin Feb 13 '20 at 17:54
  • Maybe provide an example? – jschnasse Mar 05 '20 at 08:25
  • @Bovlb Wonder if you still remeber how you settled this eventually, as I'm currently facing the exact same problem and keep running in circles around the same ideas you were considering :) – szymon Mar 15 '21 at 20:51

0 Answers0