Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between json and XML? [closed]

Tags:

json

xml

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

like image 645
Dharni Avatar asked Oct 28 '13 04:10

Dharni


People also ask

What is a difference between XML and JSON?

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.

Which is better XML or JSON Why?

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.

What is relationship between JSON and XML?

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.

Why would you use XML over JSON?

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.


Video Answer


3 Answers

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.

like image 146
sam Avatar answered Oct 28 '22 22:10

sam


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

like image 38
suhailvs Avatar answered Oct 28 '22 21:10

suhailvs


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.

like image 40
TGH Avatar answered Oct 28 '22 20:10

TGH