https://github.com/edsu/json2xml
simplistic json -> xml converter
https://github.com/edsu/json2xml
Last synced: 10 months ago
JSON representation
simplistic json -> xml converter
- Host: GitHub
- URL: https://github.com/edsu/json2xml
- Owner: edsu
- License: mit
- Created: 2012-10-03T02:24:13.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2017-01-05T15:29:36.000Z (over 9 years ago)
- Last Synced: 2025-08-24T17:31:12.119Z (10 months ago)
- Language: Python
- Size: 9.77 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
json2xml
========
A simplistic JSON to XML converter, created mainly as a way to kill time
one evening after a
[tweet](https://twitter.com/pabinkley/status/253279453738835969)
from @pbinkley. Yes, you are entitled to ask why I would ever want to
convert JSON to XML. No, I'm not going to provide an answer :-)
Example
-------
From the command line:
% ./json2xml.py tweet.json | xmllint --format - > tweet.xml
Or from your program:
```python
from json2xml import json2xml
print json2xml("tweet.json", tag_name="tweet")
```
Or if you have a python data structure created by something like json.loads
and you would like xml for it, get a TreeBuilder for it:
```python
from json2xml import data2builder
from xml.etree.ElementTree import tostring
data = {"foo": "bar", "baz": [1, 2, 3]}
builder = data2builder(data, tag_name="data")
doc = builder.close()
print tostring(doc)
```