linkeddata / rdflib.js

Linked Data API for JavaScript
http://linkeddata.github.io/rdflib.js/doc/
Other
564 stars 143 forks source link

rdflib.js does not support JSON-LD with named graphs #526

Closed RinkeHoekstra closed 2 years ago

RinkeHoekstra commented 2 years ago

I have JSON-LD files with (nested) named graphs.

Looking at the JSON-LD parser here:

https://github.com/linkeddata/rdflib.js/blob/23386aeb2d3421cd40e39067972b0f8890517a96/src/jsonldparser.js#L68-L98

It appears that it only asserts quads in the "base" graph, and ignores any triples in a nested @graph key for the triple.

A flattened structure for a triple-in-a-graph will look like this:

{
      "@graph": [
        {
          "@id": "https://example.com/someSubject",
          "https://example.com/somePredicate": {
            "@language": "en",
            "@value": "some literal value"
          }
        }
      ],
      "@id": "https://example.com/someGraphIdentifier"
}

This will attempt to create a new property in the store from the "uri" @graph, with a value that is the array containing the one triple... and this fails silently.

timbl commented 2 years ago

I'm not a Json-LD expert. I imagine when the parser was aded JSON-LD only did triples? Now when is does can we put that into the quadstore using quads?

Does JSOn-LD allow anonymous graphs to (like N3/Sparql? curly brackets)? If so we can serialize N3 data in it.

bourgeoa commented 2 years ago

@angelo-v ?