问题
I am trying to reproduce the example code from https://github.com/RDFLib/rdflib-jsonld as below:
from rdflib import Graph, plugin
from rdflib.serializer import Serializer
testrdf = '''
@prefix dc: <http://purl.org/dc/terms/> .
<http://example.org/about>
dc:title "Someone's Homepage"@en .
'''
g = Graph().parse(data=testrdf, format='n3')
print(g.serialize(format='json-ld', indent=4))
However, it seems my python output was not printed as same as the expected result.
The result should be:
{
"@id": "http://example.org/about",
"http://purl.org/dc/terms/title": [
{
"@language": "en",
"@value": "Someone's Homepage"
}
]
}
but I got these output
b'[\n {\n "@id": "http://example.org/about",\n "http://purl.org/dc/terms/title": [\n {\n "@language": "en",\n "@value": "Someone\'s Homepage"\n }\n ]\n }\n]'
Is there any extra setup that I have to do in order to get the proper output?
来源:https://stackoverflow.com/questions/39990392/python-rdflib-plugin-printed-unread-json