Quantcast
Channel: How to set up the ID of a json element in rdflib - Stack Overflow
Viewing all articles
Browse latest Browse all 2

How to set up the ID of a json element in rdflib

$
0
0

Context

I am loading a rdf file in rdflib, and am trying to export it in json-ld.

The original rdf looks like:

<cim:Substation rdf:ID="_1234"><cim:IdentifiedObject.name>A substation</cim:IdentifiedObject.name></cim:Substation>

The exported json-lib looks like:

{"@id": "file:///path/to/original/xml#_418866779","@type": "cim:Substation","cim:IdentifiedObject.name": "A substation"},

I cannot seem to override the file:///path/to/original/xml component in json.

Code

This is what I am doing:

from rdflib import Graphg = Graph(    # Giving an identifier or base does not seem to change anything)g.parse('path to rdf')js = g.serialize(    format="json-ld",    encoding="utf-8",    destination='path to json',    sort_keys=True,  # repeatable output is Good.    context={ some relevant entries (rdf, cim)  },    auto_compact=True,    # giving base does not seem to change anything)

QuestionHow can I set/override the first component of the ID in the exported json-ld?


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images