PyLD is a Python implementation of a JSON-LD processor, providing tools for working with Linked Data in JSON. It offers core JSON-LD operations such as compaction, expansion, flattening, and framing, adhering to the JSON-LD 1.1 specification. The library is actively maintained, with its current version 3.0.0 released in February 2024. While there isn't a fixed public release cadence, the project shows ongoing development and significant updates.
pip install pyldVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the core functionalities of `pyld` including `compact`, `expand`, and `flatten` operations using a sample JSON-LD document and context. It processes the document to show its compacted, expanded, and flattened forms.
Ensure your Python environment is version 3.10 or newer. Upgrade Python if necessary.
Install `pyld` with the `requests` or `aiohttp` extra: `pip install pyld[requests]` or `pip install pyld[aiohttp]`. Alternatively, install `requests` or `aiohttp` directly: `pip install requests`.
If combining PyLD with `rdflib`, consider using the `rdflib_pyld_compat.py` utility or explicitly convert between data structures by serializing and then re-parsing (e.g., to N-Quads) if a direct bridge is not suitable.
Install `requests` explicitly using `pip install requests` or `pip install pyld[requests]`.
Upgrade your Python environment to version 3.10 or higher.
Consult the JSON-LD 1.1 specification (linked from PyLD's documentation) for detailed explanations of compaction, expansion, and framing algorithms. Experiment with simpler contexts and gradually build up to complex ones, verifying each step. Ensure your `@context` definitions are accurate and cover the terms in your document.