Data Converter
Python library that loads JSON, JSON5, XML, YAML, or TOML into a dictionary, then writes any of those formats. Conversion is two-pass through that dict hub — there are no pairwise converters.
The PyPI name is lupaxa-data-converter. The import path is
lupaxa.data_converter. lupaxa is a namespace package.
Install
pip install lupaxa-data-converter
Requires Python 3.10+. The package pulls in PyYAML, defusedxml,
json5, and tomli-w. Python 3.10 also needs tomli; 3.11+ uses
stdlib tomllib.
This is a library only. There is no console script and no
python -m entry point.
Usage
from lupaxa.data_converter import DataConverter
payload = {"name": "Lupaxa", "formats": ["json", "json5", "xml", "yaml", "toml"]}
converter = DataConverter(payload, data_type="dict")
print(converter.to_json())
print(converter.to_json5())
print(converter.to_xml())
print(converter.to_yaml())
print(converter.to_toml())
DataConverter accepts a dictionary or a document string. Set
data_type to match the input (case-insensitive). The value is always
stored as a mapping on converter.data, then any to_* method can
write it out. Identity conversions are supported.
data_type |
Input |
|---|---|
dict |
A Python dictionary |
json |
A JSON object string (default) |
json5 |
A JSON5 object string |
xml |
An XML document string |
yaml |
A YAML mapping string |
toml |
A TOML table string |
from_dict = DataConverter({"id": 1}, data_type="dict")
from_json = DataConverter('{"id": 1}', data_type="json")
from_json5 = DataConverter("{ id: 1, }", data_type="json5")
from_xml = DataConverter("<root><id>1</id></root>", data_type="xml")
from_yaml = DataConverter("id: 1\n", data_type="yaml")
from_toml = DataConverter("id = 1\n", data_type="toml")
JSON, JSON5, YAML, and TOML documents must be mappings. Arrays and
scalars raise DataConverterError.
to_xml() wraps the mapping in root_tag (the XML source root, or
root for other sources). Pass root_tag to override it.
converter.to_xml(root_tag="item")
XML
Child elements with the same tag become a list. Attributes are stored
as @name keys and written back as attributes. A list value is
emitted as repeated elements with that key. The original root stays
on converter.root_tag.
converter = DataConverter('<person id="7"><name>Ann</name></person>', data_type="xml")
converter.data
# {"@id": "7", "name": "Ann"}
converter.to_xml()
# <person id="7">...</person>
Errors
Parse failures, type mismatches, unsupported data_type values, and
invalid XML names raise DataConverterError. Underlying parser errors
are attached as __cause__.
from lupaxa.data_converter import DataConverter, DataConverterError
try:
DataConverter("{not-json", data_type="json")
except DataConverterError as exc:
print(exc)
Helpers
These class methods convert without constructing an instance first.
dict_to_xml and json_to_xml wrap the mapping in root_tag
(default root). xml_to_json returns the element payload, not a
{root: ...} wrapper.
from lupaxa.data_converter import DataConverter
DataConverter.dict_to_xml({"id": 1}, root_tag="root")
DataConverter.json_to_xml({"id": 1}, root_tag="root")
DataConverter.xml_to_json("<root><id>1</id></root>")
DataConverter.yaml_to_dict("id: 1\n")
DataConverter.toml_to_dict("id = 1\n")
DataConverter.json5_to_dict("{ id: 1, }")
Metadata
Release files for lupaxa-data-converter 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lupaxa_data_converter-0.1.5.tar.gz | 7.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lupaxa_data_converter-0.1.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.4 kB
Release files / lupaxa_data_converter-0.1.5.tar.gz
| Download URL | lupaxa_data_converter-0.1.5.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
12d9da44ea86d6ee5c6a12a59cbab13ea4ae7b945fc03f4b1985572f584ac507
|
|
BLAKE2b-256 checksum How to use checksums |
86ab7f7beda9e0e93ef64972f66aae639a63ce24b206aae046ee06ab3d5a3746
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.
Transparency logRelease files / lupaxa_data_converter-0.1.5-py3-none-any.whl
| Download URL | lupaxa_data_converter-0.1.5-py3-none-any.whl |
|---|---|
| Size | 10.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2b9c8a5f7a26a5157f55d783b61d16742faa009d56004edd631c18e95a8ece5f
|
|
BLAKE2b-256 checksum How to use checksums |
3155419cf43225ed3899835792d16df8fac3e1aded147d63edc9c813fb4f6678
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.
Transparency log