Today I would like to discuss some data formats which several developers interact with constantly. Since we have many types of data to store, with varying ways to update and build upon, organization can quickly get messy. Thankfully someone came up with a method to fix the madness when we need to call a database and fetch results. Let’s get started.
XML or ‘Extensible Markup Language’ was introduced February 10, 1998. NSXMLParser is the ‘Apple approved’ way to go for parsing the document which looks like this:
XML is described as a ‘meta language’ which allows the user to create their own vocabulary pertaining to the information.
I see it as being very similar to object-oriented type design, in the way we have a collection of ‘Books’ in the picture above, the developer can add a ‘Book ISBN’ with title & author, similar to how objects with their respective properties are formed from classes.
Best thing about it is the popularity. XML is so widely used you can’t avoid learning about it!
Bad thing about XML is the formatting. Everything is ‘tagged’, so we need an open format<blah>, closing </blah> tag which must match or BOOM text spaghetti.
sorry if this is difficult to see!
so at the top of our chain, we have ‘response’ which holds a dictionary ‘groups’ that holds an array of dictionaries ‘type’, ‘name’, ‘items’ and so on and so forth.
JSON can quickly become very complex without bloating visibility. NSJSONSerialization is the class used to parse your JSON file making dictionary handling a touch easier.
Best thing about JSON is that it is quickly gaining traction. Foursquare, Yahoo, Google, MongoDB and several others are incorporating its use for data handling, and it is easy to learn from www.json.org