parsing xml to json in iphone

百般思念 提交于 2019-12-08 11:02:00

问题


Am writing one small application to parse from XML to JSON object for iphone. can anyone tell me the availability of open source library present to do the parsing usnig objective-c.


回答1:


There are plenty of open source solutions in objective-c to deal with JSON :

  • JSONKit : https://github.com/johnezang/JSONKit
  • SBJson (aka json-framework) : https://github.com/stig/json-framework
  • YAJL Framework : https://github.com/gabriel/yajl-objc

To deal with xml, you can use the default NSXMLParser class or some other solutions like some code I've posted here (DOM parser) : NSXMLParser retrieving wrong data from XML tags

You can also check this page which will give you a good overview of available solutions for XML parsing (and an explaination of differences between SAX and DOM parsers) : http://www.raywenderlich.com/553/how-to-chose-the-best-xml-parser-for-your-iphone-project




回答2:


Well there is a json parser available for objective c on github. Its very simple to use. You may have to write some additional code to provide input to the parser.




回答3:


I use NSPropertyListSerialization from Apple to turn a Plist XML into a dictionary. Then we just need to find something to go from dictionary to JSON.

The json-framework looks like a nice JSON generator.



来源:https://stackoverflow.com/questions/6408758/parsing-xml-to-json-in-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!