JRT – JSON to RDF Transformer
Convert any JSON document to RDF/XML (or other RDF serializations) from the command line or as a library, while automatically leveraging OWL/RDFS ontologies you supply.
Features
- Ontology‑aware mapping – classes & properties found in your OWL/RDFS ontologies are resolved first; public namespaces (FOAF, DC, …) are used only as fallback.
- UUID subject strategy – stable UUID‑v5 URIs when an id key is present, random UUID‑v4 otherwise.
- Heuristics out of the box – automatic rdfs:label, rdfs:comment, list handling, object‑property linking by literal label.
- Clean Typer CLI – jrt convert input.json --ontology path/ --output out.rdf.
- Extensible library API – integrate OntologyLoader, OntologyResolver, or GraphBuilder directly in Python code.
- 100 % PyPI‑ready – MIT‑licensed, tested with pytest, zero runtime dependencies outside rdflib & typer.
Quick start
1 – Install
# PyPI:
pip install jrt
# Or with Poetry:
poetry add jrt
2 – CLI usage
jrt convert data.json \
--output dist/data.rdf \
--ontology path/to/ontologies/file_or_directory \
--base-uri "http://example.org/resource/"
--format ttl
--ontology can be a single RDF/OWL file or a directory; all .rdf, .owl, .xml, .ttl files are loaded.
Supported output formats (--format) : xml (default), ttl, nt, json‑ld
3 – Library usage
You can find several examples in the dedicated folder
Building
from pathlib import Path
import json
from jrt.ontology import OntologyLoader
from jrt.builder import GraphBuilder
loader = OntologyLoader()
ontologies = loader.load(Path("path/to/ontologies"))
data = json.loads(Path("input.json").read_text())
builder = GraphBuilder(data=data, ontologies=ontologies,
base_uri="http://example.org/resource/")
graph = builder.build()
print(graph.serialize(format="turtle"))
Add serialization rules
This library offers the possibility of adding serialization rules to extend its capabilities and avoid the need for additional post-build work.
To do this, use the add_rule method:
from rdflib import Literal, URIRef
from jrt.builder import GraphBuilder
from typing import Union, List
json_data = {
"id": "thing123",
"name": "MyThing",
"custom": "This is a custom value",
"list": ["key1", "key2", "unknown"],
"dict": {
"valid": "This is valid"
}
}
def dynamic_rule(key, value) -> Union[tuple, List(tuple)]:
# Apply transformation to elements in value.
# You can return a tuple (ex: (key, new_value))
# or a list of triples (ex: [(s1, p1, new_value_1), (s2, p2, new_value_2)])
...
static_rule_uri = URIRef(...)
static_rule_literal = Literal(..., datatype=...)
builder = GraphBuilder(data=json_data, ...)
# Add new rules
builder.add_rule('custom', static_rule_literal)
builder.add_rule('dict', static_rule_uri)
builder.add_rule('list', dynamic_rule)
graph = builder.build()
Running the CLI from source
poetry run jrt convert examples/jsons/simple.json --output output.rdf
Development
git clone https://github.com/bloodbee/jrt.git
cd jrt-python
poetry install --with dev
# run tests
pytest -q
Contributing
- Fork the repo and create your feature branch (git checkout -b feat/my‑feature).
- Commit your changes with clear messages.
- Ensure all tests pass (pytest).
- Submit a pull request.
License
Released under the MIT License. See LICENSE for the full text.
© 2025 Mathieu Dufour. All trademarks and names are property of their respective owners.
Metadata
Release files for jrt 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jrt-0.3.2.tar.gz | 7.8 kB | Without provenance | Details for jrt-0.3.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jrt-0.3.2-py3-none-any.whl | Python 3 | none | any | Details for jrt-0.3.2-py3-none-any.whl |
Total release size: 17.2 kB
Release files / jrt-0.3.2.tar.gz
| Download URL | jrt-0.3.2.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2bfa8af97a73339d19b923c8166ded50f7419b394f1d98c7cd0dc052a10f52bf
|
|
BLAKE2b-256 checksum How to use checksums |
4716649fa179cfc8e6ad397dff404aca770a1df969afd5b02c09aacdd9323448
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.10.12 Linux/5.15.0-56-generic
|
Release files / jrt-0.3.2-py3-none-any.whl
| Download URL | jrt-0.3.2-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ec362152a595d59ce6a516dab3607dc7239326c4847937fd6b12a38ff87b4121
|
|
BLAKE2b-256 checksum How to use checksums |
bef79974ce6dfa23904c8861112036d59a62d50e421c1801d76205a75bb3e00d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.10.12 Linux/5.15.0-56-generic
|
Security for jrt 0.3.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.