- Notifications
You must be signed in to change notification settings - Fork 579
Closed
Description
JSON-LD @graph section can be used to specify contents of a particular named graph identified by @id. When importing a document with such section into Graph, which is not context-aware, the contents of @graph section is lost. This is demonstrated by the following test failing under rdflib==6.0.1.
import json from rdflib import Graph, URIRef def test_jsonld_with_graph(): """Try to parse a JSON-LD document with a @graph entry in it.""" document = [ { '@id': 'https://spdx.org/licenses/', '@graph': [ { '@id': 'https://spdx.org/licenses/GPL-3.0-only', '@type': 'https://spdx.org/licenses/ListedLicense', }, ], }, ] graph = Graph() graph.parse( data=json.dumps(document), format='json-ld', ) assert ( URIRef('https://spdx.org/licenses/GPL-3.0-only'), URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), URIRef('https://spdx.org/licenses/ListedLicense'), ) in graphIf to replace Graph() with ConjunctiveGraph() in this test, it passes.
It can be argued that the behavior is logical, as plain Graph() cannot contain named graphs, — but perhaps an exception message would be helpful here? Just to let the user know what is going on, and what can be done. Otherwise, it might be hard to debug the problem. Maybe it is already discussed in the docs but I did not find it?
Metadata
Metadata
Assignees
Labels
No labels