DivyaMenon
DivyaMenon

Reputation: 311

Json-LD: Linking documents using Json-LD

I am creating a desktop application using node-webkit.

The purpose of creating the application is to add documents and that anyone can comment on the document. The document will be split into paragraphs and people can comment on the paragraphs. Each of the paragraphs will be considered as different sections. I would like to link each section (or paragraph) with the comments using JSON-LD.

I am new to JSON-LD and I would like to know how it can be used.

Upvotes: 1

Views: 436

Answers (1)

Gregg Kellogg
Gregg Kellogg

Reputation: 1906

In a document (an HTML document, anyway), sections (or any element) can be identified using the @id attribute, which typically becomes a fragment identifier for the document. For instance, http://www.w3.org/TR/json-ld/#abstract is a URL with the "abstract" fragment identifier, if you look at the html source, you'll see the following:

<section id="abstract" class="introductory" property="dcterms:abstract" datatype="" typeof="bibo:Chapter" resource="#abstract" rel="bibo:chapter"><h2 aria-level="1" role="heading" id="h2_abstract">Abstract</h2>
  <p>JSON is a useful data serialization and messaging format.
    This specification defines JSON-LD, a JSON-based format to serialize
    Linked Data. The syntax is designed to easily integrate into deployed
    systems that already use JSON, and provides a smooth upgrade path from
    JSON to JSON-LD.
    It is primarily intended to be a way to use Linked Data in Web-based
    programming environments, to build interoperable Web services, and to
    store Linked Data in JSON-based storage engines.</p>
</section>

(note that some of this is automatically generated, so there is other non-relevant boiler plate as well).

This provides you one mechanism of describing the structure of a document using JSON-LD:

{
  "@id": "http://www.w3.org/TR/json-ld",
  "@type": "bibo:Document",
 "bibo:chapter": [{
    "@id": "#abstract"
  }, {
    "@id": "#sotd"
  }, {
    "@id": "#references"
  }],
}

Note, in this case, the JSON-LD is defined to have the same URI (URL) of the HTML document, so the "#abstract" really expands to http://www.w3.org/TR/json-ld#abstract, this providing you a way to reference that section, and an identifier for the section. Much more is possible.

In fact, many W3C specifications are marked up in RDFa, as both RDFa and JSON-LD are RDF formats, you can actually turn this document into JSON-LD with an appropriate too, such as the RDF distiller I maintain. For example, try the following in your browser: http://rdf.greggkellogg.net/distiller?fmt=jsonld&in_fmt=rdfa&uri=http://www.w3.org/TR/json-ld/#abstract.

Upvotes: 3

Related Questions