Sunday, September 8, 2013

what is main different XL and JSON goal?

19 down vote accepted

What is JSON?

JSON (JavaScript Object Notation) is a lightweight text-based open standard designed for human-readable data interchange. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers.
Borrowing a JSON sample from Wikipedia, a JSON representation of a person might look like:
{
    "firstName" : "John",
    "lastName"  : "Smith",
    "address"   :
    {
        "street": "21 2nd Street",
        "city"  : "New York",
        "state" : "NY",
        "zip"   : "10021"
    },
    "phoneNumber":
    [
        {
            "type"  : "home",
            "number": "212 555-1234"
        },
        {
            "type"  : "fax",
            "number": "646 555-4567"
        }
    ]
}

What is XML?

XML (eXtensible Markup Language) is a simple, very flexible text format derived from SGML. According to Wikipedia, XML is a set of rules for encoding documents in machine-readable form. [... It's goals] emphasize simplicity, generality, and usability over the Internet. It is a textual data format[...].
Again borrowing a XML sample from Wikipedia, an XML representation of a person might look like:
<person firstName="John" lastName="Smith">
    <address street="21 2nd Street" city="New York" state="NY" zip="10021" />
    <phoneNumber type="home" number="212 555-1234" />
    <phoneNumber type="fax"  number="646 555-4567" />
</person>

Comparison

Based on these simple definitions, it's understandable that one could conclude that JSON and XML are comparable. If your goal is to use one or the other for simple data interchange over the Internet,
 as exhibited by the simple examples above, that goal is surely attainable and JSON and XML are, indeed, mostly comparable.
However, as you dig deeper into the specifications of each you begin to realize they are completely different standards with similar goals; each with overlapping use cases where one is much better
suited than the other and where they are equivalent solutions (where the choice is a matter of the specific use case).
Though it may be just a bit biased, The Fat-Free Alternative to XML from the JSON site
 lists some good points of comparison. There are also the XML vs JSON !!! Dont compare.
 and JSON Pros and Cons blog entries with some bullet points for comparison.

Similarities

  • May be used for textual data interchange; no obscure format that is not easily readable by humans.
  • Allows data to be represented in a structured manner, providing a level of data relationships.
  • Internationalization using Unicode.
  • Programming language agnostic; may be used in many programming languages.
  • May be used to interface heterogeneous systems; as long as all systems use an agreed data representation contract, communication between heterogeneous systems is possible.
  • Open standards; membership to any governing body is not required to acquire the 
  • specifications (JSON is defined in the IETF RFC #4627 and XML is defined as a W3C specification) and there are no restrictive licenses (JSON, XML).

Differences

  • JSON has a simple notation that may be quickly adopted by developers.
  • JSON's lightweight nature lends it towards improved Internet user experience by decreasing performance bottlenecks.
  • JSON's simple notation, borrowed from JavaScript, makes it easier and more performant to de/serialize the data representation to common data structures.
  • JSON is available in ECMAScript, 5th edition, making it available to all applications (most notably, web browsers) with an integrated ECMAScript engine.
  • XML is a document markup language, providing semantics that gives additional meaning to data; JSON does not have this ability.
  • XML has a broader range of specifications that cover such things as schemas for data 
  • definition and validation, namespaces, stylesheets, transformations, data expressions and
  •  many others.
  • XML has been around longer and is widely adopted by many businesses; affording it greater documentation, programming language support, tooling support, community experience, off-the-shelf product support, etc.
  • XML's robust standards makes it a better solution for flexible (or sometimes, rigid ... in 
  • a beneficial way) business-to-business communication.

No comments:

Post a Comment