在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:hay/xml2json开源软件地址:https://github.com/hay/xml2json开源编程语言:Python 100.0%开源软件介绍:XML2JSONThis module is deprecated and will not be updated anymore (May 2019)
Deprecated documentationPython script converts XML to JSON or the other way around UsageMake this executable
Then invoke it from the command line like this
Or the other way around
Without the
Additional the options: Strip text (#text and #tail) in the json
Strip namespace in the json
In code
InstallationEither clone this repo or use
Licensexml2json is released under the terms of the MIT license. ContributorsThis script was originally written by R.White, Rewritten to a command line utility by Hay Kranen with contributions from George Hamilton (gmh04) and Dan Brown (jdanbrown) LinksHow it worksxml2json relies on ElementTree for the XML parsing. This is based on pesterfish.py but uses a different XML->JSON mapping. The XML -> JSON mapping is described here XML JSON <e/> "e": null <e>text</e> "e": "text" <e name="value" /> "e": { "@name": "value" } <e name="value">text</e> "e": { "@name": "value", "#text": "text" } <e> <a>text</a ><b>text</b> </e> "e": { "a": "text", "b": "text" } <e> <a>text</a> <a>text</a> </e> "e": { "a": ["text", "text"] } <e> text <a>text</a> </e> "e": { "#text": "text", "a": "text" } This is very similar to the mapping used for Yahoo Web Services This is a mess in that it is so unpredictable -- it requires lots of testing (e.g. to see if values are lists or strings or dictionaries). For use in Python this could be vastly cleaner. Think about whether the internal form can be more self-consistent while maintaining good external characteristics for the JSON. Look at the Yahoo version closely to see how it works. Maybe can adopt that completely if it makes more sense... R. White, 2006 November 6 |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论