What is the difference between json and XML?Which is better in performance aspect while working with android?Why json is described as lightweight?
JSON is a data interchange format and only provides a data encoding specification. XML is a language to specify custom markup languages, and provides a lot more than data interchange. With its strict semantics, XML defined a standard to assert data integrity of XML documents, of any XML sub-language.
Why JSON is Better Than XML. XML is much more difficult to parse than JSON. JSON is parsed into a ready-to-use JavaScript object.
JSON is data-oriented, whereas XML is document-oriented. JSON does not provide display properties, whereas XML does (as it's a Markup Language). JSON supports array, whereas XML does not. JSON is less secured than XML.
XML advantages over JSON One of the most significant advantages of XML is that we can put metadata into the tags in the form of attributes. JSON simply lacks this capability. In JSON, attributes will be added as other member fields in data representation that may NOT be desired.
I suggest you to read the following link below first
JSON and XML comparison
The first comment clearly explains your first two questions.
and for the last question my suggestion would be JSON, The reason is that JSON is light weight and also its very easy to handle and parse when comparing to XML formats. also I believe that JSON started overtaking the technology over XML in many aspects. There are tons and tons of examples and discussions available in web to support the JSON format over XML.
And for Android, since it is a technology which is going to rule the world for next few decades you must decide whether you need to choose the older technology(XML) which is getting down or the newer technology (JSON) which is growing up. The choice is yours.
a sample json
format is:
{
"note": {
"to": "Tove",
"from": "Jani",
"heading": "Reminder",
"body": "Don't forget me this weekend!"
}
}
were its xml
is:
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
please refer this SO question
Xml and JSON are two different formats for representing data. A common usage for both is to serve as a serialization format for objects. Which one is better comes down to personal preference. Some frameworks are better designed to work with one over the other.
As far as performance goes... JSON is less verbose, so it can be more efficient to transfer over the wire.
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