0

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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Raghav salotra
  • 820
  • 1
  • 11
  • 23
  • 1
    Apache Jena, of course, is able to parse JSON-LD, see [the docs](https://jena.apache.org/documentation/io/) – UninformedUser Jan 16 '18 at 07:06
  • @AKSW we are in process of evaluating Cayley for building knowledge graph. Any suggestions or views on that? – Raghav salotra Jan 16 '18 at 07:30
  • 1
    Please note that tool recommendations is considered off-topic on StackOverflow. That said, most triplestores/frameworks/parsing toolkits should be able to do this. – Jeen Broekstra Jan 17 '18 at 07:56

2 Answers2

2

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Gregg Kellogg
  • 1,831
  • 12
  • 8
0

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

Raghav salotra
  • 820
  • 1
  • 11
  • 23
  • this doesn't seem to work when the doc has a remote context. Any idea how to solve it? – Ann Jan 27 '20 at 15:43
  • @Ann You might want to take a look into this section https://github.com/digitalbazaar/pyld#document-loader – antonimmo Feb 15 '21 at 16:27