在Python中将JSON转换为XML [英] Convert JSON to XML in Python

查看:546
本文介绍了在Python中将JSON转换为XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在SO上看到许多问题,询问将XML转换为JSON的方法,但是我对采用另一种方法感兴趣.是否有用于将JSON转换为XML的python库?

I see a number of questions on SO asking about ways to convert XML to JSON, but I'm interested in going the other way. Is there a python library for converting JSON to XML?

什么都没有马上回来,所以我继续写了一个脚本来解决这个问题.

Nothing came back right away, so I went ahead and wrote a script that solves this problem.

Python已经允许您将JSON转换为本机字典(使用json或版本2.6及以下版本的simplejson),因此我编写了一个库,用于将本机字典转换为XML字符串.

Python already allows you to convert from JSON into a native dict (using json or, in versions < 2.6, simplejson), so I wrote a library that converts native dicts into an XML string.

https://github.com/quandyfactory/dict2xml

它支持int,float,boolean,string(和unicode),数组和dict数据类型以及任意嵌套(可以递归).

It supports int, float, boolean, string (and unicode), array and dict data types and arbitrary nesting (yay recursion).

8小时过后,我会将其发布为答案.

I'll post this as an answer once 8 hours have passed.

推荐答案

一无所获,所以我继续写了一个脚本来解决这个问题.

Nothing came back right away, so I went ahead and wrote a script that solves this problem.

Python已经允许您将JSON转换为本机字典(使用json或版本2.6及以下版本的simplejson),因此我编写了一个库,用于将本机字典转换为XML字符串.

Python already allows you to convert from JSON into a native dict (using json or, in versions < 2.6, simplejson), so I wrote a library that converts native dicts into an XML string.

https://github.com/quandyfactory/dict2xml

它支持int,float,boolean,string(和unicode),数组和dict数据类型以及任意嵌套(可以递归).

It supports int, float, boolean, string (and unicode), array and dict data types and arbitrary nesting (yay recursion).

这篇关于在Python中将JSON转换为XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆