Skip to main content

rdflib extension adding JSON-LD parser and serializer

Project description

ARCHIVED

The 0.6.0 release of this tool is a tombstoning release. 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. We - maintainers - will be much more able to fix/enhance JSON-LD handing in rdflib core!

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"
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rdflib-jsonld-0.6.1.tar.gz (130.5 kB view details)

Uploaded Source

Built Distribution

rdflib_jsonld-0.6.1-py2.py3-none-any.whl (16.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file rdflib-jsonld-0.6.1.tar.gz.

File metadata

  • Download URL: rdflib-jsonld-0.6.1.tar.gz
  • Upload date:
  • Size: 130.5 kB
  • Tags: Source
  • Uploaded using 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.2 CPython/3.9.1

File hashes

Hashes for rdflib-jsonld-0.6.1.tar.gz
Algorithm Hash digest
SHA256 eda5a42a2e09f80d4da78e32b5c684bccdf275368f1541e6b7bcddfb1382a0e0
MD5 7932bd063a648c66086b0a10b2513c2a
BLAKE2b-256 5a489eaecac5f5ba6b31dd932fbbe67206afcbd24a7a696c03c6c920ac7ddc39

See more details on using hashes here.

Provenance

File details

Details for the file rdflib_jsonld-0.6.1-py2.py3-none-any.whl.

File metadata

  • Download URL: rdflib_jsonld-0.6.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using 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.2 CPython/3.9.1

File hashes

Hashes for rdflib_jsonld-0.6.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 bcf84317e947a661bae0a3f2aee1eced697075fc4ac4db6065a3340ea0f10fc2
MD5 d509b5e15df33efd8eb4b11effce37fc
BLAKE2b-256 d0d2760527679057a7dad67f4e41f3e0c463b247f0bdbffc594e0add7c9077d6

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page