Difference between XML and JSON
S.NoXML JSON
1 Abbreviation:
XML stands for Extensible
Markup Language.
Abbreviation:
JSON stands for JavaScript Object
Notation.
2 Meaning:
XML is a markup language that
defines a set of rules for encoding
documents in a format that is both
human-readable and machine-
readable. It is defined in the XML
1.0 Specification produced by the
W3C, and several other related
specifications,all gratis open
standards.The design goals of
XML emphasize simplicity,
generality, and usability over the
Internet.It is a textual data format
with strong support via Unicode
for the languages of the world.
Although the design of XML
focuses on documents, it is widely
used for the representation of
arbitrary data structures, for
example in web services.
Meaning:
JSON is a text-based open standard
designed for human-readable data
interchange. It is derived from the
JavaScript scripting language for
representing simple data structures and
associative arrays, called objects.
Despite its relationship to JavaScript, it
is language-independent, with parsers
available for many languages.The
JSON format is often used for
serializing and transmitting structured
data over a network connection. It is
used primarily to transmit data
between a server and web application,
serving as an alternative to XML.
3 Type of format:
Markup language
Type of format:
Data interchange
4 Extended from:
SGML
Extended from:
JavaScript
5 Developed by:
World Wide Web Consortium
Developed by:
The JSON format was originally
specified by Douglas Crockford for
using it at State Software, a company
co-founded by Crockford, starting
around 2001.
6 Data types:
Does not provide any notion of
data types. One must rely on XML
Schema for adding type
information.
Data types:
Provides scalar data types and the
ability to express structured data
through arrays and objects.
7 Support for arrays:
Arrays have to be expressed by
conventions, for example through
the use of an outer placeholder
Support for arrays:
Native array support.
element that models the arrays
contents as inner elements.
Typically, the outer element uses
the plural form of the name used
for inner elements.
8 Support for objects :
Objects have to be expressed by
conventions, often through a
mixed use of attributes and
elements.
Support for objects :
Native object support.
9 Null support:
Requires use of xsi:nil on
elements in an XML instance
document plus an import of the
corresponding namespace.
Null support:
Natively recognizes the null value.
10 Comments:
Native support and usually
available through APIs.
Comments:
Not supported.
11 Namespaces :
Supports namespaces, which
eliminates the risk of name
collisions when combining
documents. Namespaces also
allow existing XML-based
standards to be safely extended.
Namespaces :
No concept of namespaces. Naming
collisions are usually avoided by
nesting objects or using a prefix in an
object member name (the former is
preferred in practice).
12 Formatting decisions :
Complex. Requires a greater
effort to decide how to map
application types to XML
elements and attributes. Can
create heated debates whether an
element-centric or attribute-
centric approach is better.
Formatting decisions :
Simple. Provides a much more direct
mapping for application data. The only
exception may be the absence of
date/time literal.
13 Size :
Documents tend to be lengthy in
size, especially when an element-
centric approach to formatting is
used.
Size :
Syntax is very terse and yields
formatted text where most of the space
is consumed (rightly so) by the
represented data.
14 Parsing in JavaScript :
Requires an XML DOM
implementation and additional
application code to map text back
into JavaScript objects.
Parsing in JavaScript :
No additional application code
required to parse text; can use
JavaScript's eval function.
15 Learning curve :
Generally tends to require use of
Learning curve :
Very simple technology stack that is
several technologies in concert:
XPath, XML Schema, XSLT,
XML Namespaces, the DOM, and
so on.
already familiar to developers with a
background in JavaScript or other
dynamic programming languages.
16 Tools :
Enjoys a mature set of tools
widely available from many
industry vendors.
Tools :
Rich tool support—such as editors and
formatters—is scarce.
17 Microsoft .NET Framework :
Very good and mature support
since version 1.0 of the .NET
Framework. XML support is
available as part of the Base Class
Library (BCL). For unmanaged
environments, there is MSXML.
Microsoft .NET Framework :
None so far, except an initial
implementation as part of ASP.NET
AJAX.
18 Platform and language :
Parsers and formatters are widely
available on many platforms and
languages (commercial and open
source implementations).
Platform and language :
Parsers and formatters are available
already on many platforms and in
many languages. Consult json.org for a
good set of references. Most
implementations for now tend to be
open source projects.
19 Integrated language :
Industry vendors are currently
experimenting with support
literally within languages. See
Microsoft's LINQ project for
more information.
Integrated language :
Is natively supported in
JavaScript/ECMAScript only.
References:
http://en.wikipedia.org/wiki/XML
http://en.wikipedia.org/wiki/JSON
http://www.vinaytechs.com/2009/10/introduction-to-javascript-object.html
And, further updates on difference between questions and answers, please visit my blog @
http://onlydifferencefaqs.blogspot.in/