Awesome Open Source
Awesome Open Source

RDFLib plugin providing JSON-LD parsing and serialization

This is an implementation of JSON-LD for RDFLib. For more information about this technology, see the JSON-LD website.

This implementation will:

  • read in an JSON-LD formatted document and create an RDF graph
  • serialize an RDF graph to JSON-LD formatted output


The easiest way to install the RDFLib JSON-LD plugin is directly from PyPi using pip by running the command below:

pip install rdflib-jsonld

Otherwise you can download the source and install it directly by running:

python install

Using the plug-in JSONLD serializer/parser with RDFLib

The plugin parser and serializer are automatically registered if installed by setuptools.

>>> from rdflib import Graph, plugin
>>> from rdflib.serializer import Serializer

>>> testrdf = '''
... @prefix dc: <> .
... <>
...     dc:title "Someone's Homepage"@en .
... '''

>>> g = Graph().parse(data=testrdf, format='n3')

>>> print(g.serialize(format='json-ld', indent=4))
    "@id": "",
    "": [
            "@language": "en",
            "@value": "Someone's Homepage"

>>> context = {"@vocab": "", "@language": "en"}
>>> print(g.serialize(format='json-ld', context=context, indent=4))
    "@context": {
        "@language": "en",
        "@vocab": ""
    "@id": "",
    "title": "Someone's Homepage"

Building the Sphinx documentation

If Sphinx is installed, Sphinx documentation can be generated with:

$ python build_sphinx

The documentation will be created in ./build/sphinx.

Continuous integration tests

Build Status

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
python (51,910
json (1,154
parser (499
rdf (82
serializer (67
json-ld (47

Find Open Source By Browsing 7,000 Topics Across 59 Categories