semvec/pypi-packages huggingface dataset:
rdflib-jsonld-without-2to3 0.7.0
rdflib extension adding JSON-LD parser and serializer (without 2to3)
License: BSD

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 <http://www.w3.org/TR/json-ld/>`_
for `RDFLib <https://github.com/RDFLib/rdflib>`_.
For more information about this technology, see the `JSON-LD website <http://json-ld.org/>`_.

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:

.. code-block:: shell

    pip install rdflib-jsonld
    


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

.. code-block:: shell

    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.

.. code-block:: python

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