8

What is the difference between json and XML?Which is better in performance aspect while working with android?Why json is described as lightweight?

Dharni
  • 149
  • 1
  • 3
  • 10
  • 1
    both are file format, having their own syntaxes used for data exchange between client-server or between devices as response. its depend upon the requirement, but json is much more versatile than xml. – Aman Gupta Oct 28 '13 at 04:43
  • 1
    possible duplicate of [What are the pros and cons of XML and JSON?](http://stackoverflow.com/questions/3536893/what-are-the-pros-and-cons-of-xml-and-json) – ckv Oct 28 '13 at 04:54
  • posible duplicate [what is the difference between json and xml](http://stackoverflow.com/questions/2620270/what-is-the-difference-between-json-and-xml) – Engineer Oct 28 '13 at 05:00

3 Answers3

9

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.

Community
  • 1
  • 1
sam
  • 2,426
  • 2
  • 20
  • 29
6

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

Community
  • 1
  • 1
suhailvs
  • 20,182
  • 14
  • 100
  • 98
3

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.

TGH
  • 38,769
  • 12
  • 102
  • 135