As we can see, it takes a lot less code to parse/build JSON objects with the NSJSONSerialization
class as compared to parsing/building XML objects. However, we do have a lot more control on how the document is parsed using the NSXMLParser
class. The key thing to keep in mind with both the NSJSONSerialization
class and the NSXMLParser
class is that we need to remember to check that optional variables do not contain a nil value before attempting to use them.
While it seems that the majority of newer services are using the JSON format over XML, it is good to have a working knowledge of both formats because there is still a large percentage of services that use XML.