In my app I use multiple Google APIs, and in the documentation of all of them it gives me two options:
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?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With