Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is JSON usually recommended over XML in the Google API documentation?

Tags:

json

xml

In my app I use multiple Google APIs, and in the documentation of all of them it gives me two options:

  • JSON (Recommended)
  • XML

Now, when sending requests and retrieving responses why is JSON better? Xcode has a native built in xml parser, and for JSON you must use a JSON parser like AFNetworking. What makes JSON stand out? Is it more efficient or faster?

like image 255
David Albro Avatar asked Oct 18 '12 13:10

David Albro


2 Answers

When you compare the sizes of JSON and XML representations of the same object, JSON is much smaller.

So, when using it to transfer data over a network (like the Internet), it is much more efficient to use JSON.

It is also a simpler standard to implement and use than XML is and is therefore easier to process and parse (meaning less CPU overhead).

For most applications, there is no need for some of the more advanced uses of XML, so JSON is a good alternative.

like image 199
Oded Avatar answered Sep 20 '22 09:09

Oded


JSON is smaller and there is les overhead then with XML.

Yes XML can be parsed by the NSXMLParser, but since this is a SAX parser it takes more lines of code to build a good parser.

Als since iOS 5 JSON is als nativily available, NSJSONSerialization

AFNetworking is not a JSON parser, it will use the native NSJSONSerialization if avalalable or else one you supplied.

like image 40
rckoenes Avatar answered Sep 23 '22 09:09

rckoenes