Online visitors

People learning around the world

Online

—

Visitors exploring W3Schools

Online visitors by country Circles show approximate country locations. The country list provides the visitor counts.

Circles represent countries, not exact visitor locations.

Country

Online

Loading country activity…

    Difference Between JSON and XML

    JSON Tutorials


    JSON and XML both of the technologies are used for representing data in a proper human understandable format and are independent of any computer language. In fact, these can be used with various languages on various platforms. But XML lacks behind due to some lack of acceptance and features. In comparison to JSON (JavaScript Object Notation), XML (Extensible Markup Language) seems more verbose. JSON is considered as a compact version of painting data in a human-understandable format but may be difficult to understand at one glance by a newbie. Whereas it becomes easy to understand to by a newbie to go through an XML document. In this tutorial, you will see the significant points that bring differentiation among JSON and XML and make JSON more trending than XML.

    Distinguishing XML with JSON

    XML JSON
    XML (Extensible Markup Language). JSON (JavaScript Object Notation).
    Slower in constructing an XML data representation format. Faster than XML for constructing data representation format.
    Less simple to read than JSON. JSON is simpler to read than XML.
    XML is a type of markup language. JSON is a means to characterize objects.
    XML is a bit more flexible in detailing of data. JSON is not much flexible as compared to XML, but since it deals with objects, so it does not need much detail.
    XML does not support the concept of array JSON supports representing data in the form of an array.
    XML is more secure as compared to JSON. JSON seems less secured as compared to XML.
    In parsing, the XML DOM (Document Object Model) allows access and editing of XML data. In the case of parsing, the eval method of JavaScript can parse JSON data.
    XML data representing format is not self-describing. JSON data format is self-describing.

    Differentiating JSON and XML Using a Code Snippet

    Data representation in JSON Format:

    {
      "employees": [
        {
          "name": "Alex",
          "location": "USA"
        },
        {
          "name": "Lalit",
          "location": "Canada"
        },
        {
          "name": "Deeksha",
          "location": "India"
        }
      ]
    };

    Same data representation XML Format:

    <employees>
         <employee>
             <name> Alex </name>
             <location> USA </location>
         </employee>
         <employee>
             <name> Lalit </name>
             <location> Canada </location>
         </employee>
         <employee>
             <name> Deeksha </name>
             <location> India </location>
         </employee>
    </employees>


    Found This Page Useful? Share It!
    Get the Latest Tutorials and Updates
    Join us on Telegram

    Notifications

    Updates are enabled for this browser.

    Receive new tutorials, articles and learning resources. You can turn updates off anytime.