JSON vs XML

Good day!

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_doc2

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.

JSON stands for JavaScript Object Notation which this author must confess he enjoys looking at over XML. JSON is quite versatile as a data-storing document, with the ability to hold objects, arrays, values, and strings. Not as explicit as XML, JSON is more subtle.

b58XS

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

 

Advertisements
Standard

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s