Skip to main content

A JSON to RDF transformer library that maps arbitrary JSON to RDF using heuristics and ontologies.

Project description

JRT‑Python – JSON → 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-python

# Or with Poetry:
poetry add jrt-python

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

from pathlib import Path
import json
from jrt.ontology import OntologyLoader
from jrt.graph_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"))

Development

git clone https://github.com/bloodbee/jrt-python.git
cd jrt-python
poetry install --with dev

# run tests
pytest -q

Running the CLI from source

poetry run jrt convert examples/jsons/simple.json --output output.rdf

Contributing

  1. Fork the repo and create your feature branch (git checkout -b feat/my‑feature).
  2. Commit your changes with clear messages.
  3. Ensure all tests pass (pytest).
  4. 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.

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

jrt-0.1.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jrt-0.1.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file jrt-0.1.0.tar.gz.

File metadata

  • Download URL: jrt-0.1.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.10.12 Linux/5.15.0-56-generic

File hashes

Hashes for jrt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 42c8a1981029e6d78fefa0804234483bf5e6c1db1a60af35244d52f71dc08aa1
MD5 021726351d22dae181a81f2fa9aa671b
BLAKE2b-256 28ed0e06b09a4d01e0de6a54bbf3a6475e518bd1537c48db706a7173860cf235

See more details on using hashes here.

File details

Details for the file jrt-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: jrt-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.10.12 Linux/5.15.0-56-generic

File hashes

Hashes for jrt-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2578a62bf64aa997994c155fa52229a127125d188c3641c493800a8fa374b6b4
MD5 07c8e921834aeabb60fa17c0d984951f
BLAKE2b-256 867cbe1b0245ba302a521564bed458e62d7c525848785979e3c41e9186572286

See more details on using hashes here.

Supported by

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