JSON-LD is a JSON-based format for serializing data in (a superset of) RDF as JSON and interpreting JSON contents as RDF; similarly to RDF/XML, JSON-LD provides for several ways to encode the same triples (or quads).

The rdfpro-jsonld module extends Sesame RIO with support for the JSON-LD format. JSON-LD writing is directly implemented by the module, while parsing reuses the lightweight Semargl JSONLD parser, which is adapted to the Sesame API.

In order to use the rdfpro-jsonld library you have to include the following dependency in your pom.xml:

<dependency>
  <groupId>eu.fbk.rdfpro</groupId>
  <artifactId>rdfpro-jsonld</artifactId>
  <version>0.6</version>
</dependency>

If you don’t use Maven, you have to download and include the following JARs in the classpath:

Note that the three Sesame JARs are not necessary in case the openrdf-sesame-2.8.6-onejar.jar file is already included. The SLF4J API is used by Sesame for logging. You need to include also an implementation (e.g., Logback) for logging to work.

No additional action is required to use the JSON-LD parser: just specify RDFFormat.JSONLD when creating the parser with Sesame RIO. The JSON-LD writer, instead, requires the specification of the RioSetting JSONLD.ROOT_TYPES. Its value is the set of class URIs associated to ‘top-level’ RDF resources in the produced JSON-LD. More in details, the JSON produced by the writer contains an array of JSON structures, one for each RDF resource of one of the configured root types. The JSON of RDF resources that are not root types is instead nested in the JSON of root type resources.

Back to top

Last Published: 2022/02/04.

Reflow Maven skin by Andrius Velykis.

Data and Knowledge Management tools