-
Notifications
You must be signed in to change notification settings - Fork 576
Closed
Labels
awaiting feedbackMore feedback is needed from the author of the PR or Issue.More feedback is needed from the author of the PR or Issue.
Description
JSON-LD serialization apparently loses XSD type information.
from rdflib import Graph, Literal, URIRef, XSD
graph: Graph = Graph()
graph.add(
(
URIRef("https://test.subject"),
URIRef("https://test.predicate"),
Literal("test type", datatype=XSD.string),
)
)
## 1. check literal type of constructed graph object
# pass
assert all(o.datatype for o in graph.objects())
## 2. check literal type of xml parsed graph object
xml_serialized: str = graph.serialize(format="xml")
graph_xml_parsed: Graph = Graph().parse(data=xml_serialized, format="xml")
# pass
assert all(o.datatype for o in graph_xml_parsed.objects())
## 3. check literal type of json-ld parsed graph object (fails)
json_ld_serialized: str = graph.serialize(format="json-ld")
graph_json_parsed: Graph = Graph().parse(data=json_ld_serialized, format="json-ld")
# fail
assert all(o.datatype for o in graph_json_parsed.objects())
Metadata
Metadata
Assignees
Labels
awaiting feedbackMore feedback is needed from the author of the PR or Issue.More feedback is needed from the author of the PR or Issue.