Skip to content

[json-ld serialisation] Context.to_dict() is not implemented (anymore?) #2138

@proycon

Description

@proycon

The to_dict() method is missing on Context:

Though this seems to have been implemented and merged before: RDFLib/rdflib-jsonld#51 , it is no longer present in the current codebase. However, it is still referenced: https://github.com/RDFLib/rdflib/blob/main/rdflib/plugins/serializers/jsonld.py#L126 , so this leads to an error if you pass an explicit Context instance:

>>> g.serialize(format='json-ld', auto_compact=True,context=c3)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/proycon/work/codemetapy/env/lib/python3.10/site-packages/rdflib/graph.py", line 1186, in serialize
    serializer.serialize(stream, base=base, encoding="utf-8", **args)
  File "/home/proycon/work/codemetapy/env/lib/python3.10/site-packages/rdflib/plugins/serializers/jsonld.py", line 84, in serialize
    obj = from_rdf(
  File "/home/proycon/work/codemetapy/env/lib/python3.10/site-packages/rdflib/plugins/serializers/jsonld.py", line 126, in from_rdf
    context_data = context.to_dict()
AttributeError: 'Context' object has no attribute 'to_dict'

Perhaps the solution is to re-apply the old pull request?

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingformat: JSON-LDRelated to JSON-LD format.regressionSomething stopped workingserializationRelated to serialization.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions