========
json2xml
========
.. image:: https://badge.fury.io/py/json2xml.svg
.. image:: https://static.pepy.tech/personalized-badge/json2xml?period=total&units=international_system&left_color=blue&right_color=orange&left_text=Downloads
:target: https://pepy.tech/project/json2xml
.. image:: https://github.com/vinitkumar/json2xml/actions/workflows/pythonpackage.yml/badge.svg
.. image:: https://img.shields.io/pypi/pyversions/json2xml.svg
.. image:: https://readthedocs.org/projects/json2xml/badge/?version=latest
:target: https://json2xml.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
.. image:: https://codecov.io/gh/vinitkumar/json2xml/branch/master/graph/badge.svg?token=Yt2h55eTL2
:target: https://codecov.io/gh/vinitkumar/json2xml
json2xml is a Python library that allows you to convert JSON data into XML format. It's simple, efficient, and easy to use.
Documentation: https://json2xml.readthedocs.io.
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.
Features
^^^^^^^^
json2xml supports the following features:
* Conversion from a `json` string to XML
* Conversion from a `json` file to XML
* Conversion from an API that emits `json` data to XML
Usage
^^^^^
You can use the json2xml library in the following ways:
.. code-block:: python
from json2xml import json2xml
from json2xml.utils import readfromurl, readfromstring, readfromjson
# Convert JSON data from a URL to XML
data = readfromurl("https://api.publicapis.org/entries")
print(json2xml.Json2xml(data).to_xml())
# Convert a JSON string to XML
data = readfromstring(
'{"login":"mojombo","id":1,"avatar_url":"https://avatars0.githubusercontent.com/u/1?v=4"}'
)
print(json2xml.Json2xml(data).to_xml())
# Convert a JSON file to XML
data = readfromjson("examples/licht.json")
print(json2xml.Json2xml(data).to_xml())
Custom Wrappers and Indentation
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
By default, a wrapper `all` and pretty `True` is set. However, you can easily change this in your code like this:
.. code-block:: python
from json2xml import json2xml
from json2xml.utils import readfromurl, readfromstring, readfromjson
data = readfromstring(
'{"login":"mojombo","id":1,"avatar_url":"https://avatars0.githubusercontent.com/u/1?v=4"}'
)
print(json2xml.Json2xml(data, wrapper="all", pretty=True).to_xml())
Outputs this:
.. code-block:: xml
<?xml version="1.0" ?>
<all>
<login type="str">mojombo</login>
<id type="int">1</id>
<avatar_url type="str">https://avatars0.githubusercontent.com/u/1?v=4</avatar_url>
</all>
Omit List item
^^^^^^^^^^^^^^
Assume the following json input
.. code-block:: json
{
"my_items": [
{ "my_item": { "id": 1 } },
{ "my_item": { "id": 2 } }
],
"my_str_items": ["a", "b"]
}
By default, items in an array are wrapped in <item></item>.
Default output:
.. code-block:: xml
<?xml version="1.0" ?>
<all>
<my_items type="list">
<item type="dict">
<my_item type="dict">
<id type="int">1</id>
</my_item>
</item>
<item type="dict">
<my_item type="dict">
<id type="int">2</id>
</my_item>
</item>
</my_items>
<my_str_items type="list">
<item type="str">a</item>
<item type="str">b</item>
</my_str_items>
<empty type="list"/>
</all>
However, you can change this behavior using the item_wrap property like this:
.. code-block:: python
from json2xml import json2xml
from json2xml.utils import readfromurl, readfromstring, readfromjson
data = readfromstring('{"my_items":[{"my_item":{"id":1} },{"my_item":{"id":2} }],"my_str_items":["a","b"]}')
print(json2xml.Json2xml(data, item_wrap=False).to_xml())
Outputs this:
.. code-block:: xml
<?xml version="1.0" ?>
<all>
<my_items type="list">
<my_item type="dict">
<id type="int">1</id>
</my_item>
<my_item type="dict">
<id type="int">2</id>
</my_item>
</my_items>
<my_str_items type="str">a</my_str_items>
<my_str_items type="str">b</my_str_items>
</all>
Optional Attribute Type Support
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
You can also specify if the output XML needs to have type specified or not. Here is the usage:
.. code-block:: python
from json2xml import json2xml
from json2xml.utils import readfromurl, readfromstring, readfromjson
data = readfromstring(
'{"login":"mojombo","id":1,"avatar_url":"https://avatars0.githubusercontent.com/u/1?v=4"}'
)
print(json2xml.Json2xml(data, wrapper="all", pretty=True, attr_type=False).to_xml())
Outputs this:
.. code-block:: xml
<?xml version="1.0" ?>
<all>
<login>mojombo</login>
<id>1</id>
<avatar_url>https://avatars0.githubusercontent.com/u/1?v=4</avatar_url>
</all>
The methods are simple and easy to use and there are also checks inside of code to exit cleanly
in case any of the input(file, string or API URL) returns invalid JSON.
How to run tests
^^^^^^^^^^^^^^^^
This is provided by pytest, which is straight forward.
.. code-block:: console
virtualenv venv -p $(which python3.9)
pip install -r requirements-dev.txt
python setup.py install
pytest -vv
Help and Support to maintain this project
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- You can sponsor my work for this plugin here: https://github.com/sponsors/vinitkumar/
History
=======
5.0.5 / 2024-08-31
==================
* tests (json2xml): add test for encoding
* fix missing encoding indication on pretty mode (#213)
* chore(deps): bump webob from 1.8.7 to 1.8.8 in /docs (#212)
5.0.4 / 2024-08-08
==================
* feat: enforce the version requirements in the correct way
5.0.3 / 2024-08-08
==================
* feat: remove python 3.9, python 3.8 from setup identifier
* feat: update 3.13 to beta3 (#208)
* chore(deps): bump urllib3 from 1.26.18 to 1.26.19 (#207)
* chore(deps): bump certifi from 2023.7.22 to 2024.7.4 in /docs (#206)
* chore(deps): bump urllib3 from 1.26.18 to 1.26.19 in /docs (#205)
* feat: update to actions to v20 of node
* fix: dependabot security issues and a new release version
* fix: try beta1 as beta2 fails to untar and extract
* fix: lint and deps issue
* fix: resolve issues with python 3.13 version and also encoding
* fix: CI build failures
* fix: update changelog for the docs
* fix: update to latest version of urllib3 (#195)
* chore(deps): bump urllib3 from 1.26.13 to 1.26.18 (#192)
* docs: generate changelog
* chore: bump version
* feat: get local working for 3.12 and fix some code quality issue
* feat: add new python3.12 final (#191)
* chore(deps): bump urllib3 from 1.26.7 to 1.26.17 in /docs (#190)
* Fix/make docs better (#186)
* fix: issue with hardcoded year
* fix: remove build files
* feat: upgrade sphinx theme
* fix: upgrade to latest rc2 package
* fix: issues with ruff linting, use isinstance in place of type
* fix: make readme better
* chore(deps): bump tornado from 6.3.2 to 6.3.3 in /docs (#185)
* chore: test python312rc1 (#184)
* chore(deps): bump certifi from 2022.12.7 to 2023.7.22 in /docs (#183)
* chore(deps): bump pygments from 2.10.0 to 2.15.0 in /docs (#182)
5.0.2 / 2024-06-10
==================
* fix: try beta1 as beta2 fails to untar and extract
* fix: lint and deps issue
* fix: resolve issues with python 3.13 version and also encoding
* fix: CI build failures
* fix: generate changelog
* Add Python 3.13 support (#201)
* chore(deps): bump jinja2 from 3.0.2 to 3.1.3 in /docs (#197)
* fix: bump the version to the latest release number
* Merge remote-tracking branch 'origin/master'
* fix: update changelog for the docs
* fix: update to latest version of urllib3 (#195)
* chore(deps): bump urllib3 from 1.26.13 to 1.26.18 (#192)
* docs: generate changelog
* chore: bump version
* feat: get local working for 3.12 and fix some code quality issue
* feat: add new python3.12 final (#191)
* chore(deps): bump urllib3 from 1.26.7 to 1.26.17 in /docs (#190)
* Fix/make docs better (#186)
* fix: issue with hardcoded year
* fix: remove build files
* feat: upgrade sphinx theme
* fix: upgrade to latest rc2 package
* fix: issues with ruff linting, use isinstance in place of type
* fix: make readme better
* chore(deps): bump tornado from 6.3.2 to 6.3.3 in /docs (#185)
* chore: test python312rc1 (#184)
* chore(deps): bump certifi from 2022.12.7 to 2023.7.22 in /docs (#183)
* chore(deps): bump pygments from 2.10.0 to 2.15.0 in /docs (#182)
5.0.0 / 2024-05-11
==================
* fix: add python3.12
* fix: bye bye py 3.9 👋🏻
* feat:try python3.13
* chore(deps): bump urllib3 from 1.26.13 to 1.26.18 (#192)
* feat: get local working for 3.12 and fix some code quality issue
* chore(deps): bump certifi from 2022.12.7 to 2023.7.22 in /docs (#183)
* chore(deps): bump pygments from 2.10.0 to 2.15.0 in /docs (#182)
4.1.0 / 2023-11-07
==================
* chore(deps): bump urllib3 from 1.26.13 to 1.26.18 (#192, #195)
4.0.1 / 2023-10-13
==================
* feat: get local working for 3.12 and fix some code quality issue
* Fix/make docs better (#186)
* fix: issue with hardcoded year
* feat: upgrade sphinx theme
* fix: issues with ruff linting, use isinstance in place of type
* fix: make readme better
* chore(deps): bump tornado from 6.3.2 to 6.3.3 in /docs (#185)
* chore(deps): bump certifi from 2022.12.7 to 2023.7.22 in /docs (#183)
* chore(deps): bump pygments from 2.10.0 to 2.15.0 in /docs (#182)
4.0.0 / 2023-07-19
==================
* Updated to Python 3.12 beta 4
* Added check for pypy 3.10
* Dropped support for Python 3.7
* Updated fixture for attrs with dict and removed comment (#170)
3.21.0 / 2023-01-18
===================
* Implemented list item with attributes (#169)
* Added python3.12 alpha4 to the fix (#168)
* Replaced requests with urllib3 (#167)
* Added security reporting guidelines
* Added CodeQL workflow for GitHub code scanning (#160)
* Set default to False for list_headers (#164)
* Fixed ci issue due to mypy update on python3.11 (#166)
* Updated certifi from 2021.10.8 to 2022.12.7 in /docs (#162)
* Fixed file opening issue
* Celebrated release of Python 3.11 (#159)
3.20.0 / 2022-10-16
===================
* Made dependencies more flexible (#158)
* Used SystemRandom for secure random integer generation (#156)
3.19.5 / 2022-09-18
===================
* Fixed issues #138 and #151, added 2 new unit tests (#154)
* Fixed unit tests for #152 (#153)
3.19.4 / 2022-07-24
===================
* Transitioned from unittest to pytest (#149)
* Upgraded python test to python311beta (#148)
* Tested new version of 3.10 and 3.11 (#147)
3.19.3 / 2022-07-01
===================
* Added UTF-8 encoding type to @readfromjson function in utils.py for Korean language support (#145)
3.19.2 / 2022-06-09
===================
* Escaped xml char when having attrs (#144)
* Adjusted pytest config setting for easier logging
* Bumped python 3.10 and 3.11 version (#142)
3.19.1 / 2022-06-05
===================
* Bumped version of docs building
* Updated waitress from 2.1.1 to 2.1.2 in /docs (#141)
* Updated docs for dicttoxml (#140)
3.19.0 / 2022-05-20
===================
* Set xsi location (#135)
* Repeated list headers (#138)
* Added support for python3.11 (#139)
* Improved docs for dicttoxml (#134)
* Fixed types working check for ci mypy (#133)
* Added mypy support to ci (#132)
* Generated changelog
* Removed logging by default (#131)
* Merged two dev requirements files (#129)
* Removed old unused config
* Added types (#125)
* Fixed issue with twine check
* Fixed issue with long description
* Refactored: xmltodict is only test dependency now (#124)
* Added correct list of contributors
* Generated changelog
* Improved dicttoxml (#121)
* Added correct badge
* Started using codecov
* Fixed flake8 tests
* Added coverage to the mix
* Fixed lint issues and CI
* Checked new CI stuff like lint and coverage
* Bumped version and generated changelog
* Fixed issue with wrong output for boolean list
* Made pull requests trigger action runs
3.18.0 / 2022-04-23
===================
* Bumped version
* Improved dicttoxml (#121)
* Added correct badge
* Started using codecov
* Fixed flake8 tests
* Added coverage to the mix
* Fixed lint issues and CI
* Checked new CI stuff like lint and coverage
* Bumped version and generated changelog
* Fixed issue with wrong output for boolean list
* Made pull requests trigger action runs
3.17.1 / 2022-04-20
===================
* Fixed issue with wrong output for boolean list
* Made pull requests trigger action runs
3.17.0 / 2022-04-18
===================
* Fixed return of correct xml type for bool (#119)
* Added download counter
* Checked latest alpha (#116)
* Checked latest alpha (#115)
* Updated waitress from 2.0.0 to 2.1.1 in /docs (#114)
* Only python3 wheels are created now
3.15.0 / 2022-02-24
===================
* Merged remote-tracking branch 'origin/master'
* Bumped version and prepared for new release
* Added new python versions to test against (#110)
* Fixed perflint (#109)
* Supported latest version of 3.10 and 3.11 alpha3 (#98)
* Generated changelog
* Removed unused imports
* Bumped version
* Fixed issue with uncaught UnicodeDecodeError
* Cancelled jobs for concurrent builds in same PR
* Stabilized pypi
* Updated tox config
v3.14.0 / 2022-02-10
====================
* Removed unused imports
* Bumped version
* Fixed issue with uncaught UnicodeDecodeError
* fix: remove unused imports
* bump version
* fix: issue with uncaught UnicodeDecodeError
* cancel jobs for concurrent builds in same PR
* pypi is stable now
* feat: update tox config
v3.11.0 / 2022-01-31
====================
* bump version
* feat: remove comments
* Feat: install pytest separately and run pytests now
* fix tox
* add some documentation on testing
* split testing libs away from release
* fix: update changelog
* bump version to 3.10.0
* fix: we support Python3.7+ now (#101)
* Issue: #99 dicttoxml igores the root param (#100)
v3.10.0 / 2022-01-29
====================
* bump version to 3.10.0
* fix: we support Python3.7+ now (#101)
* Issue: #99 dicttoxml igores the root param (#100)
* feat: bump to a rc1 version
* Add support for Python3.11 alpha and upgrade pytest and py (#97)
* Feat: drop 3.11.0 alphas from the test matrix for now
* feat: find the versions that are in the CI
* fix: typo in the name of python 3.11 version
* sunsetting python 3.6 and add support for python3.11 alpha
* chore: prepare for release 3.9.0
* fix email
* fix readme
* - update readme - add tests - refactor
* resolve #93
* chore: run black on readme doc
* fix: more issues
* fix: garbage in history
* feat: generate history
v3.9.0 / 2021-12-19
===================
* feat: generate history
* feat: item_wrap for str and int (#93)
v3.8.4 / 2021-10-24
===================
* bump version
* fix: version bump and readme generator
v3.8.3 / 2021-10-24
===================
* bump version
* feat: reproduce the error in the test (#90)
* Feat/version (#88)
* Feat/docs theme change (#87)
* Feat/docs theme change (#86)
* Feat/docs theme change (#85)
* Feat/docs theme change (#84)
* Feat/docs theme change (#83)
* feat: update the docs theme (#82)
v3.8.0 / 2021-10-07
===================
* Feat/security improvements (#81)
* :arrow_up: feat: python 3.10 released (#79)
v3.7.0 / 2021-09-11
===================
* :bookmark: feat: final release for v3.7.0
* :bookmark: feat: bump version
v3.7.0beta2 / 2021-09-10
========================
* Feat/cleanup and deprecation fix (#78)
* item ommision (#76)
* Create FUNDING.yml
v3.7.0beta1 / 2021-08-28
========================
* Feat/fork and update dict2xml (#75)
* chore(deps-dev): bump pip from 18.1 to 19.2 (#73)
* Delete .travis.yml
* chore(deps-dev): bump lxml from 4.6.2 to 4.6.3 (#68)
* Bump lxml from 4.1.1 to 4.6.2 (#66)
v3.6.0 / 2020-11-12
===================
* Feat/wip exceptions (#65)
* Add .deepsource.toml
* feat: upgrade the actions
* feat: try & support more os and python versions
* Update pythonpackage.yml
v3.5.0 / 2020-08-24
===================
* feat: remove six as dependency as we are python3 only, resolves #60 (#61)
* feat: update makefile for the correct command
v3.4.1 / 2020-06-10
===================
* fix: issues with pypi release and bump version
* Feat/attr type docs (#58)
* fix: conflicts
* Feat/attr type docs (#57)
* Merge github.com:vinitkumar/json2xml
* Update json2xml.py (#56)
* Merge github.com:vinitkumar/json2xml
* feat: fix typo in the readme
v3.3.3 / 2020-02-05
===================
* Update README.rst
* fix: issue with pypi uploads
* fix: version
* bump version
* Update pythonpackage.yml
* Refactor/prospector cleanup (#50)
* Update pythonpackage.yml
* Create pythonpackage.yml
* Update README.rst
* fix: typo in readme
* bump version
* Feature/attribute support (#48)
* Feature/attribute support (#47)
* chore: bump version
* fix: remove print statement in json read because it confuses people
* fix typo in readme
v3.0.0 / 2019-02-26
===================
* Fix/coveralls (#43)
* update coverage report (#42)
* Merge pull request #41 from vinitkumar/fix/coveralls
* add python coveralls
* Merge pull request #40 from vinitkumar/refactor/cookiecutter
* update coverage
* add image for coveralls
* coverage and coveralls integrations
* try and trigger coveralls too
* fix code block in readme
* add doc about custom wrapper
* try at reducing the dependencies
* add tests for custom wrappers as well
* add tests for actualy dict2xml conversion
* fix: remove missing import
* fix: code syntax highlight in the readme again
* fix: code syntax highlight in the readme again
* fix: code syntax highlight in the readme
* chore: update readme with code samples
* test: add testcases for the different utils method
* remove unused imports
* check the third method for generating dict from json string too
* run correct test files
* fix tests
* update requirements and setuptools
* refactor the module into more maintainable code
* chore: add boilerplate
* remove all legacy
* Fix/cleanup (#38)
* cleanup: remove unused modules (#37)
* Merge pull request #35 from vinitkumar/improve-structure
* cleanup
* one again try to get the build working
* travis need full version for latest supported python
* do not hardcode version in a series
* update grammar
* fix conflicts
* Update LICENSE
* cleanup readme
* remove cli
* some cleanup and update the tests
* Update readme.md
* Cleanup Readme.md
* Update issue templates
* fix vulnerabilities in requests
Raw data
{
"_id": null,
"home_page": "https://github.com/vinitkumar/json2xml",
"name": "json2xml",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "json2xml",
"author": "Vinit Kumar",
"author_email": "mail@vinitkumar.me",
"download_url": "https://files.pythonhosted.org/packages/f3/c5/b66499a21acaca87cd90e32325e80ec7595418c0793e0f76983df3f14e02/json2xml-5.0.5.tar.gz",
"platform": null,
"description": "========\njson2xml\n========\n\n.. image:: https://badge.fury.io/py/json2xml.svg\n.. image:: https://static.pepy.tech/personalized-badge/json2xml?period=total&units=international_system&left_color=blue&right_color=orange&left_text=Downloads\n :target: https://pepy.tech/project/json2xml\n\n.. image:: https://github.com/vinitkumar/json2xml/actions/workflows/pythonpackage.yml/badge.svg\n.. image:: https://img.shields.io/pypi/pyversions/json2xml.svg\n.. image:: https://readthedocs.org/projects/json2xml/badge/?version=latest\n :target: https://json2xml.readthedocs.io/en/latest/?badge=latest\n :alt: Documentation Status\n.. image:: https://codecov.io/gh/vinitkumar/json2xml/branch/master/graph/badge.svg?token=Yt2h55eTL2\n :target: https://codecov.io/gh/vinitkumar/json2xml\n\njson2xml is a Python library that allows you to convert JSON data into XML format. It's simple, efficient, and easy to use.\n\nDocumentation: https://json2xml.readthedocs.io.\n\nThe 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.\n\nFeatures\n^^^^^^^^\n\njson2xml supports the following features:\n\n* Conversion from a `json` string to XML\n* Conversion from a `json` file to XML\n* Conversion from an API that emits `json` data to XML\n\nUsage\n^^^^^\n\nYou can use the json2xml library in the following ways:\n\n\n.. code-block:: python\n\n from json2xml import json2xml\n from json2xml.utils import readfromurl, readfromstring, readfromjson\n\n # Convert JSON data from a URL to XML\n data = readfromurl(\"https://api.publicapis.org/entries\")\n print(json2xml.Json2xml(data).to_xml())\n\n # Convert a JSON string to XML\n data = readfromstring(\n '{\"login\":\"mojombo\",\"id\":1,\"avatar_url\":\"https://avatars0.githubusercontent.com/u/1?v=4\"}'\n )\n print(json2xml.Json2xml(data).to_xml())\n\n # Convert a JSON file to XML\n data = readfromjson(\"examples/licht.json\")\n print(json2xml.Json2xml(data).to_xml())\n\n\nCustom Wrappers and Indentation\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nBy default, a wrapper `all` and pretty `True` is set. However, you can easily change this in your code like this:\n\n.. code-block:: python\n\n from json2xml import json2xml\n from json2xml.utils import readfromurl, readfromstring, readfromjson\n\n data = readfromstring(\n '{\"login\":\"mojombo\",\"id\":1,\"avatar_url\":\"https://avatars0.githubusercontent.com/u/1?v=4\"}'\n )\n print(json2xml.Json2xml(data, wrapper=\"all\", pretty=True).to_xml())\n\n\nOutputs this:\n\n.. code-block:: xml\n\n <?xml version=\"1.0\" ?>\n <all>\n <login type=\"str\">mojombo</login>\n <id type=\"int\">1</id>\n <avatar_url type=\"str\">https://avatars0.githubusercontent.com/u/1?v=4</avatar_url>\n </all>\n\nOmit List item\n^^^^^^^^^^^^^^\n\nAssume the following json input\n\n.. code-block:: json\n\n {\n \"my_items\": [\n { \"my_item\": { \"id\": 1 } },\n { \"my_item\": { \"id\": 2 } }\n ],\n \"my_str_items\": [\"a\", \"b\"]\n }\n\nBy default, items in an array are wrapped in <item></item>.\n\nDefault output:\n\n.. code-block:: xml\n\n <?xml version=\"1.0\" ?>\n <all>\n <my_items type=\"list\">\n <item type=\"dict\">\n <my_item type=\"dict\">\n <id type=\"int\">1</id>\n </my_item>\n </item>\n <item type=\"dict\">\n <my_item type=\"dict\">\n <id type=\"int\">2</id>\n </my_item>\n </item>\n </my_items>\n <my_str_items type=\"list\">\n <item type=\"str\">a</item>\n <item type=\"str\">b</item>\n </my_str_items>\n <empty type=\"list\"/>\n </all>\n\nHowever, you can change this behavior using the item_wrap property like this:\n\n.. code-block:: python\n\n from json2xml import json2xml\n from json2xml.utils import readfromurl, readfromstring, readfromjson\n\n data = readfromstring('{\"my_items\":[{\"my_item\":{\"id\":1} },{\"my_item\":{\"id\":2} }],\"my_str_items\":[\"a\",\"b\"]}')\n print(json2xml.Json2xml(data, item_wrap=False).to_xml())\n\nOutputs this:\n\n.. code-block:: xml\n\n <?xml version=\"1.0\" ?>\n <all>\n <my_items type=\"list\">\n <my_item type=\"dict\">\n <id type=\"int\">1</id>\n </my_item>\n <my_item type=\"dict\">\n <id type=\"int\">2</id>\n </my_item>\n </my_items>\n <my_str_items type=\"str\">a</my_str_items>\n <my_str_items type=\"str\">b</my_str_items>\n </all>\n\nOptional Attribute Type Support\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nYou can also specify if the output XML needs to have type specified or not. Here is the usage:\n\n .. code-block:: python\n\n from json2xml import json2xml\n from json2xml.utils import readfromurl, readfromstring, readfromjson\n\n data = readfromstring(\n '{\"login\":\"mojombo\",\"id\":1,\"avatar_url\":\"https://avatars0.githubusercontent.com/u/1?v=4\"}'\n )\n print(json2xml.Json2xml(data, wrapper=\"all\", pretty=True, attr_type=False).to_xml())\n\n\nOutputs this:\n\n.. code-block:: xml\n\n <?xml version=\"1.0\" ?>\n <all>\n <login>mojombo</login>\n <id>1</id>\n <avatar_url>https://avatars0.githubusercontent.com/u/1?v=4</avatar_url>\n </all>\n\n\nThe methods are simple and easy to use and there are also checks inside of code to exit cleanly\nin case any of the input(file, string or API URL) returns invalid JSON.\n\nHow to run tests\n^^^^^^^^^^^^^^^^\n\nThis is provided by pytest, which is straight forward.\n\n .. code-block:: console\n\n virtualenv venv -p $(which python3.9)\n pip install -r requirements-dev.txt\n python setup.py install\n pytest -vv\n\n\nHelp and Support to maintain this project\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n- You can sponsor my work for this plugin here: https://github.com/sponsors/vinitkumar/\n\n\n\nHistory\n=======\n\n5.0.5 / 2024-08-31\n==================\n\n * tests (json2xml): add test for encoding\n * fix missing encoding indication on pretty mode (#213)\n * chore(deps): bump webob from 1.8.7 to 1.8.8 in /docs (#212)\n\n5.0.4 / 2024-08-08\n==================\n\n * feat: enforce the version requirements in the correct way\n\n5.0.3 / 2024-08-08\n==================\n\n * feat: remove python 3.9, python 3.8 from setup identifier\n * feat: update 3.13 to beta3 (#208)\n * chore(deps): bump urllib3 from 1.26.18 to 1.26.19 (#207)\n * chore(deps): bump certifi from 2023.7.22 to 2024.7.4 in /docs (#206)\n * chore(deps): bump urllib3 from 1.26.18 to 1.26.19 in /docs (#205)\n * feat: update to actions to v20 of node\n * fix: dependabot security issues and a new release version\n * fix: try beta1 as beta2 fails to untar and extract\n * fix: lint and deps issue\n * fix: resolve issues with python 3.13 version and also encoding\n * fix: CI build failures\n * fix: update changelog for the docs\n * fix: update to latest version of urllib3 (#195)\n * chore(deps): bump urllib3 from 1.26.13 to 1.26.18 (#192)\n * docs: generate changelog\n * chore: bump version\n * feat: get local working for 3.12 and fix some code quality issue\n * feat: add new python3.12 final (#191)\n * chore(deps): bump urllib3 from 1.26.7 to 1.26.17 in /docs (#190)\n * Fix/make docs better (#186)\n * fix: issue with hardcoded year\n * fix: remove build files\n * feat: upgrade sphinx theme\n * fix: upgrade to latest rc2 package\n * fix: issues with ruff linting, use isinstance in place of type\n * fix: make readme better\n * chore(deps): bump tornado from 6.3.2 to 6.3.3 in /docs (#185)\n * chore: test python312rc1 (#184)\n * chore(deps): bump certifi from 2022.12.7 to 2023.7.22 in /docs (#183)\n * chore(deps): bump pygments from 2.10.0 to 2.15.0 in /docs (#182)\n\n5.0.2 / 2024-06-10\n==================\n\n * fix: try beta1 as beta2 fails to untar and extract\n * fix: lint and deps issue\n * fix: resolve issues with python 3.13 version and also encoding\n * fix: CI build failures\n * fix: generate changelog\n * Add Python 3.13 support (#201)\n * chore(deps): bump jinja2 from 3.0.2 to 3.1.3 in /docs (#197)\n * fix: bump the version to the latest release number\n * Merge remote-tracking branch 'origin/master'\n * fix: update changelog for the docs\n * fix: update to latest version of urllib3 (#195)\n * chore(deps): bump urllib3 from 1.26.13 to 1.26.18 (#192)\n * docs: generate changelog\n * chore: bump version\n * feat: get local working for 3.12 and fix some code quality issue\n * feat: add new python3.12 final (#191)\n * chore(deps): bump urllib3 from 1.26.7 to 1.26.17 in /docs (#190)\n * Fix/make docs better (#186)\n * fix: issue with hardcoded year\n * fix: remove build files\n * feat: upgrade sphinx theme\n * fix: upgrade to latest rc2 package\n * fix: issues with ruff linting, use isinstance in place of type\n * fix: make readme better\n * chore(deps): bump tornado from 6.3.2 to 6.3.3 in /docs (#185)\n * chore: test python312rc1 (#184)\n * chore(deps): bump certifi from 2022.12.7 to 2023.7.22 in /docs (#183)\n * chore(deps): bump pygments from 2.10.0 to 2.15.0 in /docs (#182)\n\n5.0.0 / 2024-05-11\n==================\n\n * fix: add python3.12\n * fix: bye bye py 3.9 \ud83d\udc4b\ud83c\udffb\n * feat:try python3.13\n * chore(deps): bump urllib3 from 1.26.13 to 1.26.18 (#192)\n * feat: get local working for 3.12 and fix some code quality issue\n * chore(deps): bump certifi from 2022.12.7 to 2023.7.22 in /docs (#183)\n * chore(deps): bump pygments from 2.10.0 to 2.15.0 in /docs (#182)\n\n4.1.0 / 2023-11-07\n==================\n\n * chore(deps): bump urllib3 from 1.26.13 to 1.26.18 (#192, #195)\n\n4.0.1 / 2023-10-13\n==================\n\n * feat: get local working for 3.12 and fix some code quality issue\n * Fix/make docs better (#186)\n * fix: issue with hardcoded year\n * feat: upgrade sphinx theme\n * fix: issues with ruff linting, use isinstance in place of type\n * fix: make readme better\n * chore(deps): bump tornado from 6.3.2 to 6.3.3 in /docs (#185)\n * chore(deps): bump certifi from 2022.12.7 to 2023.7.22 in /docs (#183)\n * chore(deps): bump pygments from 2.10.0 to 2.15.0 in /docs (#182)\n\n4.0.0 / 2023-07-19\n==================\n\n * Updated to Python 3.12 beta 4\n * Added check for pypy 3.10\n * Dropped support for Python 3.7\n * Updated fixture for attrs with dict and removed comment (#170)\n\n3.21.0 / 2023-01-18\n===================\n\n * Implemented list item with attributes (#169)\n * Added python3.12 alpha4 to the fix (#168)\n * Replaced requests with urllib3 (#167)\n * Added security reporting guidelines\n * Added CodeQL workflow for GitHub code scanning (#160)\n * Set default to False for list_headers (#164)\n * Fixed ci issue due to mypy update on python3.11 (#166)\n * Updated certifi from 2021.10.8 to 2022.12.7 in /docs (#162)\n * Fixed file opening issue\n * Celebrated release of Python 3.11 (#159)\n\n3.20.0 / 2022-10-16\n===================\n\n * Made dependencies more flexible (#158)\n * Used SystemRandom for secure random integer generation (#156)\n\n3.19.5 / 2022-09-18\n===================\n\n * Fixed issues #138 and #151, added 2 new unit tests (#154)\n * Fixed unit tests for #152 (#153)\n\n3.19.4 / 2022-07-24\n===================\n\n * Transitioned from unittest to pytest (#149)\n * Upgraded python test to python311beta (#148)\n * Tested new version of 3.10 and 3.11 (#147)\n\n3.19.3 / 2022-07-01\n===================\n\n * Added UTF-8 encoding type to @readfromjson function in utils.py for Korean language support (#145)\n\n3.19.2 / 2022-06-09\n===================\n\n * Escaped xml char when having attrs (#144)\n * Adjusted pytest config setting for easier logging\n * Bumped python 3.10 and 3.11 version (#142)\n\n3.19.1 / 2022-06-05\n===================\n\n * Bumped version of docs building\n * Updated waitress from 2.1.1 to 2.1.2 in /docs (#141)\n * Updated docs for dicttoxml (#140)\n\n3.19.0 / 2022-05-20\n===================\n\n * Set xsi location (#135)\n * Repeated list headers (#138)\n * Added support for python3.11 (#139)\n * Improved docs for dicttoxml (#134)\n * Fixed types working check for ci mypy (#133)\n * Added mypy support to ci (#132)\n * Generated changelog\n * Removed logging by default (#131)\n * Merged two dev requirements files (#129)\n * Removed old unused config\n * Added types (#125)\n * Fixed issue with twine check\n * Fixed issue with long description\n * Refactored: xmltodict is only test dependency now (#124)\n * Added correct list of contributors\n * Generated changelog\n * Improved dicttoxml (#121)\n * Added correct badge\n * Started using codecov\n * Fixed flake8 tests\n * Added coverage to the mix\n * Fixed lint issues and CI\n * Checked new CI stuff like lint and coverage\n * Bumped version and generated changelog\n * Fixed issue with wrong output for boolean list\n * Made pull requests trigger action runs\n\n3.18.0 / 2022-04-23\n===================\n\n * Bumped version\n * Improved dicttoxml (#121)\n * Added correct badge\n * Started using codecov\n * Fixed flake8 tests\n * Added coverage to the mix\n * Fixed lint issues and CI\n * Checked new CI stuff like lint and coverage\n * Bumped version and generated changelog\n * Fixed issue with wrong output for boolean list\n * Made pull requests trigger action runs\n\n3.17.1 / 2022-04-20\n===================\n\n * Fixed issue with wrong output for boolean list\n * Made pull requests trigger action runs\n\n3.17.0 / 2022-04-18\n===================\n\n * Fixed return of correct xml type for bool (#119)\n * Added download counter\n * Checked latest alpha (#116)\n * Checked latest alpha (#115)\n * Updated waitress from 2.0.0 to 2.1.1 in /docs (#114)\n * Only python3 wheels are created now\n\n3.15.0 / 2022-02-24\n===================\n\n * Merged remote-tracking branch 'origin/master'\n * Bumped version and prepared for new release\n * Added new python versions to test against (#110)\n * Fixed perflint (#109)\n * Supported latest version of 3.10 and 3.11 alpha3 (#98)\n * Generated changelog\n * Removed unused imports\n * Bumped version\n * Fixed issue with uncaught UnicodeDecodeError\n * Cancelled jobs for concurrent builds in same PR\n * Stabilized pypi\n * Updated tox config\n\nv3.14.0 / 2022-02-10\n====================\n\n * Removed unused imports\n * Bumped version\n * Fixed issue with uncaught UnicodeDecodeError\n * fix: remove unused imports\n * bump version\n * fix: issue with uncaught UnicodeDecodeError\n * cancel jobs for concurrent builds in same PR\n * pypi is stable now\n * feat: update tox config\n\nv3.11.0 / 2022-01-31\n====================\n\n * bump version\n * feat: remove comments\n * Feat: install pytest separately and run pytests now\n * fix tox\n * add some documentation on testing\n * split testing libs away from release\n * fix: update changelog\n * bump version to 3.10.0\n * fix: we support Python3.7+ now (#101)\n * Issue: #99 dicttoxml igores the root param (#100)\n\nv3.10.0 / 2022-01-29\n====================\n\n * bump version to 3.10.0\n * fix: we support Python3.7+ now (#101)\n * Issue: #99 dicttoxml igores the root param (#100)\n * feat: bump to a rc1 version\n * Add support for Python3.11 alpha and upgrade pytest and py (#97)\n * Feat: drop 3.11.0 alphas from the test matrix for now\n * feat: find the versions that are in the CI\n * fix: typo in the name of python 3.11 version\n * sunsetting python 3.6 and add support for python3.11 alpha\n * chore: prepare for release 3.9.0\n * fix email\n * fix readme\n * - update readme - add tests - refactor\n * resolve #93\n * chore: run black on readme doc\n * fix: more issues\n * fix: garbage in history\n * feat: generate history\n\nv3.9.0 / 2021-12-19\n===================\n\n * feat: generate history\n * feat: item_wrap for str and int (#93)\n\nv3.8.4 / 2021-10-24\n===================\n\n * bump version\n * fix: version bump and readme generator\n\nv3.8.3 / 2021-10-24\n===================\n\n * bump version\n * feat: reproduce the error in the test (#90)\n * Feat/version (#88)\n * Feat/docs theme change (#87)\n * Feat/docs theme change (#86)\n * Feat/docs theme change (#85)\n * Feat/docs theme change (#84)\n * Feat/docs theme change (#83)\n * feat: update the docs theme (#82)\n\nv3.8.0 / 2021-10-07\n===================\n\n * Feat/security improvements (#81)\n * :arrow_up: feat: python 3.10 released (#79)\n\nv3.7.0 / 2021-09-11\n===================\n\n * :bookmark: feat: final release for v3.7.0\n * :bookmark: feat: bump version\n\nv3.7.0beta2 / 2021-09-10\n========================\n\n * Feat/cleanup and deprecation fix (#78)\n * item ommision (#76)\n * Create FUNDING.yml\n\nv3.7.0beta1 / 2021-08-28\n========================\n\n * Feat/fork and update dict2xml (#75)\n * chore(deps-dev): bump pip from 18.1 to 19.2 (#73)\n * Delete .travis.yml\n * chore(deps-dev): bump lxml from 4.6.2 to 4.6.3 (#68)\n * Bump lxml from 4.1.1 to 4.6.2 (#66)\n\nv3.6.0 / 2020-11-12\n===================\n\n * Feat/wip exceptions (#65)\n * Add .deepsource.toml\n * feat: upgrade the actions\n * feat: try & support more os and python versions\n * Update pythonpackage.yml\n\nv3.5.0 / 2020-08-24\n===================\n\n * feat: remove six as dependency as we are python3 only, resolves #60 (#61)\n * feat: update makefile for the correct command\n\nv3.4.1 / 2020-06-10\n===================\n\n * fix: issues with pypi release and bump version\n * Feat/attr type docs (#58)\n * fix: conflicts\n * Feat/attr type docs (#57)\n * Merge github.com:vinitkumar/json2xml\n * Update json2xml.py (#56)\n * Merge github.com:vinitkumar/json2xml\n * feat: fix typo in the readme\n\nv3.3.3 / 2020-02-05\n===================\n\n * Update README.rst\n * fix: issue with pypi uploads\n * fix: version\n * bump version\n * Update pythonpackage.yml\n * Refactor/prospector cleanup (#50)\n * Update pythonpackage.yml\n * Create pythonpackage.yml\n * Update README.rst\n * fix: typo in readme\n * bump version\n * Feature/attribute support (#48)\n * Feature/attribute support (#47)\n * chore: bump version\n * fix: remove print statement in json read because it confuses people\n * fix typo in readme\n\nv3.0.0 / 2019-02-26\n===================\n\n * Fix/coveralls (#43)\n * update coverage report (#42)\n * Merge pull request #41 from vinitkumar/fix/coveralls\n * add python coveralls\n * Merge pull request #40 from vinitkumar/refactor/cookiecutter\n * update coverage\n * add image for coveralls\n * coverage and coveralls integrations\n * try and trigger coveralls too\n * fix code block in readme\n * add doc about custom wrapper\n * try at reducing the dependencies\n * add tests for custom wrappers as well\n * add tests for actualy dict2xml conversion\n * fix: remove missing import\n * fix: code syntax highlight in the readme again\n * fix: code syntax highlight in the readme again\n * fix: code syntax highlight in the readme\n * chore: update readme with code samples\n * test: add testcases for the different utils method\n * remove unused imports\n * check the third method for generating dict from json string too\n * run correct test files\n * fix tests\n * update requirements and setuptools\n * refactor the module into more maintainable code\n * chore: add boilerplate\n * remove all legacy\n * Fix/cleanup (#38)\n * cleanup: remove unused modules (#37)\n * Merge pull request #35 from vinitkumar/improve-structure\n * cleanup\n * one again try to get the build working\n * travis need full version for latest supported python\n * do not hardcode version in a series\n * update grammar\n * fix conflicts\n * Update LICENSE\n * cleanup readme\n * remove cli\n * some cleanup and update the tests\n * Update readme.md\n * Cleanup Readme.md\n * Update issue templates\n * fix vulnerabilities in requests\n\n",
"bugtrack_url": null,
"license": "Apache Software License 2.0",
"summary": "Simple Python Library to convert JSON to XML",
"version": "5.0.5",
"project_urls": {
"Homepage": "https://github.com/vinitkumar/json2xml"
},
"split_keywords": [
"json2xml"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ad93ba6b8a892fa443477ccba51d80d294c15d08f849951b75f0a0c00805df1d",
"md5": "22fc987d3a91fa08daf8f74ea9b0da02",
"sha256": "9435c896729d4108d84d18fb03c550fd75dbf17666daf0f214f763a424c4d447"
},
"downloads": -1,
"filename": "json2xml-5.0.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "22fc987d3a91fa08daf8f74ea9b0da02",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 14091,
"upload_time": "2024-08-31T16:38:37",
"upload_time_iso_8601": "2024-08-31T16:38:37.865314Z",
"url": "https://files.pythonhosted.org/packages/ad/93/ba6b8a892fa443477ccba51d80d294c15d08f849951b75f0a0c00805df1d/json2xml-5.0.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f3c5b66499a21acaca87cd90e32325e80ec7595418c0793e0f76983df3f14e02",
"md5": "289abef475a0d3c4b3fc506ce719ce4b",
"sha256": "232d7b8a8a7dfbec1efbee75207a75a91496156fe0cf40cfeace43d6effe16c1"
},
"downloads": -1,
"filename": "json2xml-5.0.5.tar.gz",
"has_sig": false,
"md5_digest": "289abef475a0d3c4b3fc506ce719ce4b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 29234,
"upload_time": "2024-08-31T16:38:38",
"upload_time_iso_8601": "2024-08-31T16:38:38.969054Z",
"url": "https://files.pythonhosted.org/packages/f3/c5/b66499a21acaca87cd90e32325e80ec7595418c0793e0f76983df3f14e02/json2xml-5.0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-31 16:38:38",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "vinitkumar",
"github_project": "json2xml",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"tox": true,
"lcname": "json2xml"
}