本文介绍了在iOS中解析JSON与解析XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

场景:

我正在研究一个解析器,该解析器用于在发出请求后从服务器发送回的数据.数据格式为JSON或XML.

I am working on a parser for data which is sent back from a server after making a request. The format of data is either JSON or XML.

问题:

  1. 是否有任何理由选择其中一种而不是另一种?
  2. 解析json或解析xml哪个更快?

谢谢.

推荐答案

结帐本教程有关解析XML的信息.我可能听起来很自以为是,但是如果可以选择使用JSON,尽管我不知道您的项目所处的情况.在做出决定之前,我当然会研究项目的整个体系结构(权衡和选择).根据我的经验,了解JSON并将其与NSDictionaries和NSArrays关联比理解XML容易得多.

Checkout this tutorial about parsing XMLs. I might sound opinionated, but if there's a choice go for JSON, although I have no clue what situation your project is in. I would certainly look at the entire architecture (trade-offs and choices) of the project before making a decision. From my experience, understanding JSON and relating it to NSDictionaries and NSArrays is much easier than understanding XMLs.

这篇关于在iOS中解析JSON与解析XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 01:45