Wikipedia:Reference desk/Archives/Computing/2020 February 12

Computing desk
< February 11 << Jan | February | Mar >> Current desk >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


February 12

edit

Top-level object in JSON-LD

edit

Best practices says 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 is 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? Thanks, Bovlb (talk) 14:27, 12 February 2020 (UTC)[reply]

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.
I cross-posted this question to stackoverflow, and will update here if I see any responses. Bovlb (talk) 16:37, 12 February 2020 (UTC)[reply]

Could they just mean that the json doc should have only one document, as opposed to JSON streaming? Many libraries don't handle streaming. 2601:648:8202:96B0:0:0:0:7AC0 (talk) 10:29, 14 February 2020 (UTC)[reply]