json2xml 5.3.1__tar.gz → 6.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {json2xml-5.3.1 → json2xml-6.0.0}/CONTRIBUTING.rst +66 -10
- {json2xml-5.3.1 → json2xml-6.0.0}/HISTORY.rst +69 -1
- {json2xml-5.3.1 → json2xml-6.0.0}/PKG-INFO +265 -1
- {json2xml-5.3.1 → json2xml-6.0.0}/README.rst +264 -0
- json2xml-6.0.0/docs/benchmarks.rst +221 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/docs/index.rst +1 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/docs/installation.rst +45 -2
- json2xml-6.0.0/docs/usage.rst +229 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/json2xml/__init__.py +1 -1
- json2xml-6.0.0/json2xml/cli.py +371 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/json2xml/dicttoxml.py +1 -1
- json2xml-6.0.0/json2xml/dicttoxml_fast.py +165 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/json2xml/json2xml.py +6 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/json2xml.egg-info/PKG-INFO +265 -1
- {json2xml-5.3.1 → json2xml-6.0.0}/json2xml.egg-info/SOURCES.txt +6 -0
- json2xml-6.0.0/json2xml.egg-info/entry_points.txt +2 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/pyproject.toml +9 -1
- json2xml-6.0.0/tests/test_cli.py +685 -0
- json2xml-6.0.0/tests/test_rust_dicttoxml.py +606 -0
- json2xml-5.3.1/docs/usage.rst +0 -7
- {json2xml-5.3.1 → json2xml-6.0.0}/AUTHORS.rst +0 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/LICENSE +0 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/MANIFEST.in +0 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/docs/Makefile +0 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/docs/authors.rst +0 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/docs/conf.py +0 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/docs/contributing.rst +0 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/docs/history.rst +0 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/docs/json2xml.rst +0 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/docs/make.bat +0 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/docs/modules.rst +0 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/docs/readme.rst +0 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/json2xml/utils.py +0 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/json2xml.egg-info/dependency_links.txt +0 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/json2xml.egg-info/requires.txt +0 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/json2xml.egg-info/top_level.txt +0 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/requirements.in +0 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/setup.cfg +0 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/setup.py +0 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/tests/__init__.py +0 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/tests/conftest.py +0 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/tests/test_dict2xml.py +0 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/tests/test_json2xml.py +0 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/tests/test_missing_coverage.py +0 -0
- {json2xml-5.3.1 → json2xml-6.0.0}/tests/test_utils.py +0 -0
|
@@ -64,11 +64,13 @@ Ready to contribute? Here's how to set up `json2xml` for local development.
|
|
|
64
64
|
|
|
65
65
|
$ git clone git@github.com:your_name_here/json2xml.git
|
|
66
66
|
|
|
67
|
-
3. Install your local copy
|
|
67
|
+
3. Install your local copy using uv (recommended) or pip::
|
|
68
68
|
|
|
69
|
-
$ mkvirtualenv json2xml
|
|
70
69
|
$ cd json2xml/
|
|
71
|
-
$
|
|
70
|
+
$ uv venv
|
|
71
|
+
$ source .venv/bin/activate
|
|
72
|
+
$ uv pip install -r requirements-dev.txt
|
|
73
|
+
$ uv pip install -e .
|
|
72
74
|
|
|
73
75
|
4. Create a branch for local development::
|
|
74
76
|
|
|
@@ -76,14 +78,15 @@ Ready to contribute? Here's how to set up `json2xml` for local development.
|
|
|
76
78
|
|
|
77
79
|
Now you can make your changes locally.
|
|
78
80
|
|
|
79
|
-
5. When you're done making changes, check that your changes pass
|
|
80
|
-
tests
|
|
81
|
+
5. When you're done making changes, check that your changes pass linting and the
|
|
82
|
+
tests::
|
|
81
83
|
|
|
82
|
-
$
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
$ make check-all # Runs lint, typecheck, and tests
|
|
85
|
+
|
|
86
|
+
# Or individually:
|
|
87
|
+
$ ruff check json2xml tests
|
|
88
|
+
$ mypy json2xml tests
|
|
89
|
+
$ pytest tests/
|
|
87
90
|
|
|
88
91
|
6. Commit your changes and push your branch to GitHub::
|
|
89
92
|
|
|
@@ -93,6 +96,59 @@ Ready to contribute? Here's how to set up `json2xml` for local development.
|
|
|
93
96
|
|
|
94
97
|
7. Submit a pull request through the GitHub website.
|
|
95
98
|
|
|
99
|
+
Rust Extension Development
|
|
100
|
+
--------------------------
|
|
101
|
+
|
|
102
|
+
The ``json2xml-rs`` Rust extension provides ~29x faster performance. If you want to contribute to the Rust extension:
|
|
103
|
+
|
|
104
|
+
**Prerequisites**
|
|
105
|
+
|
|
106
|
+
Install Rust and maturin::
|
|
107
|
+
|
|
108
|
+
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
|
109
|
+
$ uv pip install maturin
|
|
110
|
+
|
|
111
|
+
**Building the Extension**
|
|
112
|
+
|
|
113
|
+
::
|
|
114
|
+
|
|
115
|
+
# Build and install in development mode
|
|
116
|
+
$ cd rust
|
|
117
|
+
$ uv pip install -e .
|
|
118
|
+
|
|
119
|
+
# Or using maturin directly
|
|
120
|
+
$ maturin develop --release
|
|
121
|
+
|
|
122
|
+
**Running Rust Tests**
|
|
123
|
+
|
|
124
|
+
::
|
|
125
|
+
|
|
126
|
+
$ pytest tests/test_rust_dicttoxml.py -v
|
|
127
|
+
|
|
128
|
+
**Running Benchmarks**
|
|
129
|
+
|
|
130
|
+
::
|
|
131
|
+
|
|
132
|
+
$ python benchmark_rust.py
|
|
133
|
+
|
|
134
|
+
**Rust Code Structure**
|
|
135
|
+
|
|
136
|
+
The Rust code is located in ``rust/src/lib.rs`` and includes:
|
|
137
|
+
|
|
138
|
+
- ``escape_xml()`` - XML character escaping
|
|
139
|
+
- ``wrap_cdata()`` - CDATA section wrapping
|
|
140
|
+
- ``convert_dict()`` - Dictionary to XML conversion
|
|
141
|
+
- ``convert_list()`` - List to XML conversion
|
|
142
|
+
- ``dicttoxml()`` - Main entry point exposed to Python
|
|
143
|
+
|
|
144
|
+
When making changes to the Rust code:
|
|
145
|
+
|
|
146
|
+
1. Ensure all existing tests pass
|
|
147
|
+
2. Add tests for new functionality
|
|
148
|
+
3. Run ``cargo fmt`` to format Rust code
|
|
149
|
+
4. Run ``cargo clippy`` for linting
|
|
150
|
+
5. Verify Python compatibility tests pass
|
|
151
|
+
|
|
96
152
|
Pull Request Guidelines
|
|
97
153
|
-----------------------
|
|
98
154
|
|
|
@@ -1,7 +1,75 @@
|
|
|
1
1
|
History
|
|
2
2
|
=======
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
6.0.0 / 2026-01-16
|
|
5
|
+
==================
|
|
6
|
+
|
|
7
|
+
**Major Release: Native Rust Extension for 29x Faster Performance**
|
|
8
|
+
|
|
9
|
+
This release introduces an optional native Rust extension built with PyO3 that provides
|
|
10
|
+
approximately 29x faster JSON to XML conversion compared to pure Python.
|
|
11
|
+
|
|
12
|
+
New Features:
|
|
13
|
+
|
|
14
|
+
* feat: add optional Rust extension (json2xml-rs) for ~29x faster performance
|
|
15
|
+
* feat: add dicttoxml_fast module with automatic backend selection
|
|
16
|
+
* feat: seamless fallback to pure Python when Rust extension is not installed
|
|
17
|
+
* feat: pre-built wheels for Linux (x86_64, aarch64), macOS (Intel, Apple Silicon), Windows
|
|
18
|
+
|
|
19
|
+
Performance Improvements:
|
|
20
|
+
|
|
21
|
+
* Small JSON (47 bytes): 33x faster
|
|
22
|
+
* Medium JSON (3.2KB): 28x faster
|
|
23
|
+
* Large JSON (32KB): 30x faster
|
|
24
|
+
* Very Large JSON (323KB): 29x faster
|
|
25
|
+
|
|
26
|
+
New Files:
|
|
27
|
+
|
|
28
|
+
* rust/ - PyO3 Rust extension source code
|
|
29
|
+
* json2xml/dicttoxml_fast.py - Auto-selecting wrapper module
|
|
30
|
+
* tests/test_rust_dicttoxml.py - 65 comprehensive tests for Rust extension
|
|
31
|
+
* benchmark_rust.py - Performance comparison script
|
|
32
|
+
* .github/workflows/build-rust-wheels.yml - CI for building wheels
|
|
33
|
+
* .github/workflows/rust-ci.yml - CI for Rust code quality
|
|
34
|
+
|
|
35
|
+
Installation:
|
|
36
|
+
|
|
37
|
+
* Pure Python: pip install json2xml
|
|
38
|
+
* With Rust acceleration: pip install json2xml-rs (then import from dicttoxml_fast)
|
|
39
|
+
|
|
40
|
+
Documentation:
|
|
41
|
+
|
|
42
|
+
* Updated README with Rust extension usage and benchmarks
|
|
43
|
+
* Updated CONTRIBUTING with Rust development guide
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
5.4.0 / 2026-01-15
|
|
47
|
+
==================
|
|
48
|
+
|
|
49
|
+
* test: add comprehensive CLI tests for 99% coverage
|
|
50
|
+
* docs: add CLI usage and cross-reference to Go version
|
|
51
|
+
* feat: add CLI support for json2xml-py (#266)
|
|
52
|
+
* chore(deps): bump urllib3 from 2.6.0 to 2.6.3 in /docs (#265)
|
|
53
|
+
* update documentation and make it more correct (#263)
|
|
54
|
+
* feat: update doc packages
|
|
55
|
+
* chore: update GitHub Actions to latest versions (#262)
|
|
56
|
+
* chore(deps): bump urllib3 from 2.5.0 to 2.6.0 in /docs (#261)
|
|
57
|
+
* feat: update python3.15.0 to alpha 3 (#260)
|
|
58
|
+
* feat: bump to match the version
|
|
59
|
+
* feat: add xPath support (#259)
|
|
60
|
+
* chore(deps): bump starlette from 0.47.2 to 0.49.1 in /docs (#257)
|
|
61
|
+
* feat: improvements to ruff and new python 3.15 (#255)
|
|
62
|
+
* Modernize Python code to 3.10+ with pyupgrade (#254)
|
|
63
|
+
* check arm build ubuntu (#253)
|
|
64
|
+
* Remove duplicate typecheck job from pythonpackage workflow
|
|
65
|
+
* Migrate from mypy to ty for type checking (#252)
|
|
66
|
+
* Add Python 3.14t (freethreaded) to testing matrix (#251)
|
|
67
|
+
* prod release (#249)
|
|
68
|
+
* bump python to latest rc2
|
|
69
|
+
* fix: switch to release candidate 2 of Python 3.14
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
5.3.1 / 2025-12-08
|
|
5
73
|
==================
|
|
6
74
|
|
|
7
75
|
* chore: bump version
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: json2xml
|
|
3
|
-
Version:
|
|
3
|
+
Version: 6.0.0
|
|
4
4
|
Summary: Simple Python Library to convert JSON to XML
|
|
5
5
|
Author-email: Vinit Kumar <mail@vinitkumar.me>
|
|
6
6
|
License: Apache Software License 2.0
|
|
@@ -33,6 +33,10 @@ Provides-Extra: test
|
|
|
33
33
|
Requires-Dist: pytest>=8.4.1; extra == "test"
|
|
34
34
|
Dynamic: license-file
|
|
35
35
|
|
|
36
|
+
.. image:: ./json2xml-hero.png
|
|
37
|
+
:alt: json2xml hero
|
|
38
|
+
|
|
39
|
+
|
|
36
40
|
========
|
|
37
41
|
json2xml
|
|
38
42
|
========
|
|
@@ -55,6 +59,8 @@ Documentation: https://json2xml.readthedocs.io.
|
|
|
55
59
|
|
|
56
60
|
The library was initially dependent on the `dict2xml` project, but it has now been integrated into json2xml itself. This has led to cleaner code, the addition of types and tests, and overall improved performance.
|
|
57
61
|
|
|
62
|
+
**Looking for a Go version?** Check out `json2xml-go <https://github.com/vinitkumar/json2xml-go>`_, a Go port of this library with identical features and a native CLI tool.
|
|
63
|
+
|
|
58
64
|
|
|
59
65
|
|
|
60
66
|
Architecture Diagram
|
|
@@ -63,6 +69,46 @@ Architecture Diagram
|
|
|
63
69
|
.. image:: ./diagram.png
|
|
64
70
|
|
|
65
71
|
|
|
72
|
+
Installation
|
|
73
|
+
^^^^^^^^^^^^
|
|
74
|
+
|
|
75
|
+
**As a Library**
|
|
76
|
+
|
|
77
|
+
.. code-block:: console
|
|
78
|
+
|
|
79
|
+
pip install json2xml
|
|
80
|
+
|
|
81
|
+
**With Native Rust Acceleration (29x faster)**
|
|
82
|
+
|
|
83
|
+
For maximum performance, install the optional Rust extension:
|
|
84
|
+
|
|
85
|
+
.. code-block:: console
|
|
86
|
+
|
|
87
|
+
# Install json2xml with Rust acceleration (when published)
|
|
88
|
+
pip install json2xml[fast]
|
|
89
|
+
|
|
90
|
+
# Or install the Rust extension separately
|
|
91
|
+
pip install json2xml-rs
|
|
92
|
+
|
|
93
|
+
The Rust extension provides **29x faster** conversion compared to pure Python. It's automatically used when available, with seamless fallback to pure Python.
|
|
94
|
+
|
|
95
|
+
*Note: The ``json2xml-rs`` package will be available on PyPI after the first Rust release.*
|
|
96
|
+
|
|
97
|
+
**As a CLI Tool**
|
|
98
|
+
|
|
99
|
+
The library includes a command-line tool ``json2xml-py`` that gets installed automatically:
|
|
100
|
+
|
|
101
|
+
.. code-block:: console
|
|
102
|
+
|
|
103
|
+
pip install json2xml
|
|
104
|
+
|
|
105
|
+
# Now you can use it from the command line
|
|
106
|
+
json2xml-py data.json
|
|
107
|
+
json2xml-py -s '{"name": "John", "age": 30}'
|
|
108
|
+
json2xml-py -u https://api.example.com/data.json
|
|
109
|
+
|
|
110
|
+
For CLI options, run ``json2xml-py --help``.
|
|
111
|
+
|
|
66
112
|
Features
|
|
67
113
|
^^^^^^^^
|
|
68
114
|
|
|
@@ -72,6 +118,7 @@ json2xml supports the following features:
|
|
|
72
118
|
* Conversion from a `json` file to XML
|
|
73
119
|
* Conversion from an API that emits `json` data to XML
|
|
74
120
|
* Compliant with the `json-to-xml` function specification from `XPath 3.1 <https://www.w3.org/TR/xpath-functions-31/#func-json-to-xml>`_
|
|
121
|
+
* **Command-line tool** for easy conversion from the terminal
|
|
75
122
|
|
|
76
123
|
Usage
|
|
77
124
|
^^^^^
|
|
@@ -289,6 +336,223 @@ Using tools directly:
|
|
|
289
336
|
ruff check json2xml tests
|
|
290
337
|
mypy json2xml tests
|
|
291
338
|
|
|
339
|
+
**Rust Extension Development**
|
|
340
|
+
|
|
341
|
+
The optional Rust extension (``json2xml-rs``) provides 29x faster performance. To develop or build the Rust extension:
|
|
342
|
+
|
|
343
|
+
Prerequisites:
|
|
344
|
+
|
|
345
|
+
.. code-block:: console
|
|
346
|
+
|
|
347
|
+
# Install Rust (if not already installed)
|
|
348
|
+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
|
349
|
+
|
|
350
|
+
# Install maturin (Rust-Python build tool)
|
|
351
|
+
uv pip install maturin
|
|
352
|
+
|
|
353
|
+
Building the extension:
|
|
354
|
+
|
|
355
|
+
.. code-block:: console
|
|
356
|
+
|
|
357
|
+
# Development build (installs in current environment)
|
|
358
|
+
cd rust
|
|
359
|
+
uv pip install -e .
|
|
360
|
+
|
|
361
|
+
# Or using maturin directly
|
|
362
|
+
maturin develop --release
|
|
363
|
+
|
|
364
|
+
# Production wheel build
|
|
365
|
+
maturin build --release
|
|
366
|
+
|
|
367
|
+
Running Rust benchmarks:
|
|
368
|
+
|
|
369
|
+
.. code-block:: console
|
|
370
|
+
|
|
371
|
+
# After building the extension
|
|
372
|
+
python benchmark_rust.py
|
|
373
|
+
|
|
374
|
+
The Rust code is in ``rust/src/lib.rs`` and uses PyO3 for Python bindings.
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
CLI Usage
|
|
378
|
+
^^^^^^^^^
|
|
379
|
+
|
|
380
|
+
The ``json2xml-py`` command-line tool provides an easy way to convert JSON to XML from the terminal.
|
|
381
|
+
|
|
382
|
+
**Basic Examples**
|
|
383
|
+
|
|
384
|
+
.. code-block:: console
|
|
385
|
+
|
|
386
|
+
# Convert a JSON file to XML
|
|
387
|
+
json2xml-py data.json
|
|
388
|
+
|
|
389
|
+
# Convert with custom wrapper element
|
|
390
|
+
json2xml-py -w root data.json
|
|
391
|
+
|
|
392
|
+
# Read JSON from string
|
|
393
|
+
json2xml-py -s '{"name": "John", "age": 30}'
|
|
394
|
+
|
|
395
|
+
# Read from stdin
|
|
396
|
+
cat data.json | json2xml-py -
|
|
397
|
+
|
|
398
|
+
# Output to file
|
|
399
|
+
json2xml-py -o output.xml data.json
|
|
400
|
+
|
|
401
|
+
# Use XPath 3.1 format
|
|
402
|
+
json2xml-py -x data.json
|
|
403
|
+
|
|
404
|
+
# Disable pretty printing and type attributes
|
|
405
|
+
json2xml-py --no-pretty --no-type data.json
|
|
406
|
+
|
|
407
|
+
**CLI Options**
|
|
408
|
+
|
|
409
|
+
.. code-block:: text
|
|
410
|
+
|
|
411
|
+
Input Options:
|
|
412
|
+
-u, --url string Read JSON from URL
|
|
413
|
+
-s, --string string Read JSON from string
|
|
414
|
+
[input-file] Read JSON from file (use - for stdin)
|
|
415
|
+
|
|
416
|
+
Output Options:
|
|
417
|
+
-o, --output string Output file (default: stdout)
|
|
418
|
+
|
|
419
|
+
Conversion Options:
|
|
420
|
+
-w, --wrapper string Wrapper element name (default "all")
|
|
421
|
+
-r, --root Include root element (default true)
|
|
422
|
+
-p, --pretty Pretty print output (default true)
|
|
423
|
+
-t, --type Include type attributes (default true)
|
|
424
|
+
-i, --item-wrap Wrap list items in <item> elements (default true)
|
|
425
|
+
-x, --xpath Use XPath 3.1 json-to-xml format
|
|
426
|
+
-c, --cdata Wrap string values in CDATA sections
|
|
427
|
+
-l, --list-headers Repeat headers for each list item
|
|
428
|
+
|
|
429
|
+
Other Options:
|
|
430
|
+
-v, --version Show version information
|
|
431
|
+
-h, --help Show help message
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
Go Version
|
|
435
|
+
^^^^^^^^^^
|
|
436
|
+
|
|
437
|
+
A Go port of this library is available at `json2xml-go <https://github.com/vinitkumar/json2xml-go>`_.
|
|
438
|
+
|
|
439
|
+
**Install the Go CLI:**
|
|
440
|
+
|
|
441
|
+
.. code-block:: console
|
|
442
|
+
|
|
443
|
+
go install github.com/vinitkumar/json2xml-go/cmd/json2xml@latest
|
|
444
|
+
|
|
445
|
+
The Go version provides the same features and a native compiled binary for maximum performance.
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
Rust Extension (PyO3)
|
|
449
|
+
^^^^^^^^^^^^^^^^^^^^^
|
|
450
|
+
|
|
451
|
+
For users who need maximum performance within Python, json2xml includes an optional native Rust extension built with PyO3:
|
|
452
|
+
|
|
453
|
+
.. code-block:: console
|
|
454
|
+
|
|
455
|
+
pip install json2xml[fast]
|
|
456
|
+
|
|
457
|
+
**Rust vs Pure Python Performance:**
|
|
458
|
+
|
|
459
|
+
.. list-table::
|
|
460
|
+
:header-rows: 1
|
|
461
|
+
:widths: 30 20 20 15
|
|
462
|
+
|
|
463
|
+
* - Test Case
|
|
464
|
+
- Pure Python
|
|
465
|
+
- Rust Extension
|
|
466
|
+
- Speedup
|
|
467
|
+
* - **Small JSON** (47 bytes)
|
|
468
|
+
- 41µs
|
|
469
|
+
- 1.3µs
|
|
470
|
+
- **33x**
|
|
471
|
+
* - **Medium JSON** (3.2 KB)
|
|
472
|
+
- 2.1ms
|
|
473
|
+
- 76µs
|
|
474
|
+
- **28x**
|
|
475
|
+
* - **Large JSON** (32 KB)
|
|
476
|
+
- 21.5ms
|
|
477
|
+
- 727µs
|
|
478
|
+
- **30x**
|
|
479
|
+
* - **Very Large JSON** (323 KB)
|
|
480
|
+
- 215ms
|
|
481
|
+
- 7.4ms
|
|
482
|
+
- **29x**
|
|
483
|
+
|
|
484
|
+
**Usage with Rust Extension:**
|
|
485
|
+
|
|
486
|
+
.. code-block:: python
|
|
487
|
+
|
|
488
|
+
# Automatic backend selection (recommended)
|
|
489
|
+
from json2xml.dicttoxml_fast import dicttoxml, get_backend
|
|
490
|
+
|
|
491
|
+
print(f"Using backend: {get_backend()}") # 'rust' or 'python'
|
|
492
|
+
|
|
493
|
+
data = {"name": "John", "age": 30}
|
|
494
|
+
xml_bytes = dicttoxml(data)
|
|
495
|
+
|
|
496
|
+
The ``dicttoxml_fast`` module automatically uses the Rust backend when available and falls back to pure Python for unsupported features (like ``xpath_format``, ``xml_namespaces``, or custom ``item_func``).
|
|
497
|
+
|
|
498
|
+
**Platform Support:**
|
|
499
|
+
|
|
500
|
+
Pre-built wheels are available for:
|
|
501
|
+
|
|
502
|
+
- Linux (x86_64, aarch64)
|
|
503
|
+
- macOS (x86_64, arm64/Apple Silicon)
|
|
504
|
+
- Windows (x86_64)
|
|
505
|
+
|
|
506
|
+
For other platforms, the pure Python version is used automatically.
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
Performance Benchmarks
|
|
510
|
+
^^^^^^^^^^^^^^^^^^^^^^
|
|
511
|
+
|
|
512
|
+
Comprehensive benchmarks comparing Python, Go, and Zig implementations:
|
|
513
|
+
|
|
514
|
+
.. list-table::
|
|
515
|
+
:header-rows: 1
|
|
516
|
+
:widths: 25 20 15 15
|
|
517
|
+
|
|
518
|
+
* - Test Case
|
|
519
|
+
- Python (CPython)
|
|
520
|
+
- Go
|
|
521
|
+
- Zig
|
|
522
|
+
* - **Small JSON** (47 bytes)
|
|
523
|
+
- 68.88ms
|
|
524
|
+
- 7.13ms
|
|
525
|
+
- 2.65ms
|
|
526
|
+
* - **Medium JSON** (2.6 KB)
|
|
527
|
+
- 73.40ms
|
|
528
|
+
- 4.85ms
|
|
529
|
+
- 2.13ms
|
|
530
|
+
* - **Large JSON** (323 KB)
|
|
531
|
+
- 420.06ms
|
|
532
|
+
- 68.88ms
|
|
533
|
+
- 5.90ms
|
|
534
|
+
* - **Very Large JSON** (1.6 MB)
|
|
535
|
+
- 2.08s
|
|
536
|
+
- 288.75ms
|
|
537
|
+
- 20.62ms
|
|
538
|
+
|
|
539
|
+
**Recommendation by Use Case:**
|
|
540
|
+
|
|
541
|
+
- **Python integration / scripting**: Use this library (json2xml)
|
|
542
|
+
- **CLI tool / moderate performance**: Use `json2xml-go <https://github.com/vinitkumar/json2xml-go>`_
|
|
543
|
+
- **Maximum performance / large files**: Use `json2xml-zig <https://github.com/vinitkumar/json2xml-zig>`_
|
|
544
|
+
|
|
545
|
+
For detailed benchmarks, see `BENCHMARKS.md <https://github.com/vinitkumar/json2xml/blob/master/BENCHMARKS.md>`_.
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
Other Implementations
|
|
549
|
+
^^^^^^^^^^^^^^^^^^^^^
|
|
550
|
+
|
|
551
|
+
This library is also available in other languages:
|
|
552
|
+
|
|
553
|
+
- **Go**: `json2xml-go <https://github.com/vinitkumar/json2xml-go>`_ - 7x faster, native compiled binary
|
|
554
|
+
- **Zig**: `json2xml-zig <https://github.com/vinitkumar/json2xml-zig>`_ - 85x faster, maximum performance
|
|
555
|
+
|
|
292
556
|
|
|
293
557
|
Help and Support to maintain this project
|
|
294
558
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|