Convert XML to JSON (and back) using Javascript

2018-12-31 05:41发布

How would you convert from XML to JSON and then back to XML?

The following tools work quite well, but aren't completely consistent:

Has anyone encountered this situation before?

8条回答
与君花间醉酒
2楼-- · 2018-12-31 06:29

The best way to do it using server side as client side doesn't work well in all scenarios. I was trying to build online json to xml and xml to json converter using javascript and I felt almost impossible as it was not working in all scenarios. Ultimately I ended up doing it server side using Newtonsoft in ASP.MVC. Here is the online converter http://techfunda.com/Tools/XmlToJson

查看更多
余生请多指教
3楼-- · 2018-12-31 06:38

I think this is the best one: Converting between XML and JSON

Be sure to read the accompanying article on the xml.com O'Reilly site, which goes into details of the problems with these conversions, which I think you will find enlightening. The fact that O'Reilly is hosting the article should indicate that Stefan's solution has merit.

查看更多
登录 后发表回答