Skip to main content

RDFLib plugin providing JSON-LD parsing and serialization

ARCHIVED

The 0.7.0 release of this tool is a come back of rdflib-jsonld without use_2to3 usage. We needed this package to be published on pypi to provide a smooth migration path when upgrading cubicweb to rdflib 6.0.

As of 2021-07-21, JSON-LD handling capability has been merged into the rdflib core `RDFLib <https://github.com/RDFLib/rdflib>`_ in its 6.0.0 release.

Please stop using this plugin as soon as you can and migrate to rdflib >= 6.0.0.

If you are forced to keep using Python <= 3.6, you will need to keep using this plugin with RDFlib 5.0.0.


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

Installation

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 setup.py 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 dcterms: <http://purl.org/dc/terms/> .
... <http://example.org/about>
...     dcterms:title "Someone's Homepage"@en .
... """

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

>>> print(g.serialize(format='json-ld', indent=4))
{
    "@id": "http://example.org/about",
    "http://purl.org/dc/terms/title": [
        {
            "@language": "en",
            "@value": "Someone's Homepage"
        }
    ]
}

>>> context = {"@vocab": "http://purl.org/dc/terms/", "@language": "en"}
>>> print(g.serialize(format='json-ld', context=context, indent=4))
{
    "@context": {
        "@language": "en",
        "@vocab": "http://purl.org/dc/terms/"
    },
    "@id": "http://example.org/about",
    "title": "Someone's Homepage"
}

Release files for rdflib-jsonld-without-2to3 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rdflib-jsonld-without-2to3 0.7.0
File Size Uploaded
rdflib-jsonld-without-2to3-0.7.0.tar.gz 114.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rdflib-jsonld-without-2to3 0.7.0
File Interpreter ABI Platform
rdflib_jsonld_without_2to3-0.7.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 130.6 kB

Release files / rdflib-jsonld-without-2to3-0.7.0.tar.gz

Download URL rdflib-jsonld-without-2to3-0.7.0.tar.gz
Size 114.0 kB
Tags Source
SHA-256 checksum
How to use checksums
63b2bb62da296720e388694380bea58f10a08d3cabdf34b43c85d3e83f93ea14
BLAKE2b-256 checksum
How to use checksums
8c18fb8ce8cdc361e7f738c5877b301fdca646921f2b89bf703a867d454bad97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / rdflib_jsonld_without_2to3-0.7.0-py2.py3-none-any.whl

Download URL rdflib_jsonld_without_2to3-0.7.0-py2.py3-none-any.whl
Size 16.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
5c13650eb405ba61258660f736c08c03c0a78f641853aea4dc709ce4ce5753a7
BLAKE2b-256 checksum
How to use checksums
b4650534295aad8e9bce307ed14a8484f96aba4730b9d3ce1101b7c54c0af519
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release history Release notifications | RSS feed

This release

0.7.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page