Featured post

Difference between protocol and delegates?

A protocol, declared with the ( @protocol syntax in Objective-C) is used to declare a set of methods that a class "adopts" (de...

Thursday, 9 April 2015

.Difference between JSON and XML which one you should prefer

JSON
  • JSON is the most natural representation for Javascript apps, and Javascript is arguably the most popular language in the world, and growing
  • JSON is one type of text-based format or standard for interchanging  data i.e. human readable.
  • JSON syntax is lighter than XML as JSON has serialized format of data having  less redundancy. JSON does not contain start and end tags.
  • JSON is light – weighted in compare to XML as it has serialized format and so faster also.
  • JSON supports datatype including integer and strings, JSON also supports array.
  • JSON has support of native objects.
  • JSON does not support Comments.
  • JSON does not have support for Namespaces.
  • JSON is data oriented and can be mapped more easily.
  • JSON uses only evel() for parsing i.e. for interpreting the JavaScript code & returns the result. It does not need any additional code for parsing.
  • For Web services, JSON is better.
  • You can not change JSON data to other format.
  • In JSON no such is interface for getting direct access to a part in JSON data-structure.
XML
  • XML is a Markup Language having format that contains set of rules for the encoding the documents which is readable for both human & machine
  • XML is not so lighter as JSON as having start and end tags and it takes more character than JSON to represent same data.
  • XML is not so light weighted as JSON.
  • XML does not provide any data type so needs to be parsed into particular datatype. No direct support for array also.
  • XML can get support of objects through mixed use of attributes & elements.
  • XML supports comments.
  • XML supports Namespaces.
  • XML is document oriented and needs more effort for mapping.
  • XML needs XML Document Object Model (DOM)                           implementation & with that additional code for mapping text back to the JavaScript objects.
  • For configuration, XML is better.
  • In XML, using XSLT you can change XML data into another format like comma –delimited, plain text, JSON, etc.
  • In XML, Using XPath, it is possible to get the direct access to a particular part of multiple parts of XML data- structure.

No comments:

Post a Comment