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