Is there a way to convert JSON-LD to N-Quads format?

1.7k views Asked by At

We have a requirement where we will be storing data in JSON-LD format for maintaining a catalog and data from the catalog will be pulled in batches to a graph database which supports the RDF data format. We have been looking at Cayley and DBgraph for this purpose, but these databases support N-Quads as their data format.

Is there a graph database which has the JSON-LD data format or is there a way to convert the JSON-LD format to the N-Quads/Turtle format?

2

There are 2 answers

0
Gregg Kellogg On

Converting JSON-LD to N-Quads (and back) are core algorithms described in the JSON-LD API specification. Any conforming JSON-LD processor supports this.

2
Raghav salotra On

Pyld provides an option to normalise jsonld to other RDF formats.

# normalize a document using the RDF Dataset Normalization Algorithm
# (URDNA2015), see: http://json-ld.github.io/normalization/spec/
normalized = jsonld.normalize(
    doc, {'algorithm': 'URDNA2015', 'format': 'application/nquads'})
# normalized is a string that is a canonical representation of the document
# that can be used for hashing, comparison, etc.

Below is the link:

https://github.com/digitalbazaar/pyld