JSON Data Format - Simple Example


JSON Data Format - Simple Example


In this JSON tutorial, I will explain about JSON data example and format json object. JSON stands for Java Script Object Notation. It is a lightweight data-interchange format for storing and exchanging data. It is easy for machines to parse and generate. The following JSON example defines an employees object, with an array of 3 employee records:

Simple Json Example

    {"firstName":"Ravi", "lastName":"Kumar"},

    {"firstName":"Sachin", "lastName":"Kumar"},

    {"firstName":"Nitin", "lastName":"Kumar"}


The following XML example also defines an employees object with 3 employee records:
XML Example
        <firstName>Ravi</firstName> <lastName>Kumar</lastName>
        <firstName>Sachin</firstName> <lastName>Kumar</lastName>
        <firstName>Nitin</firstName> <lastName>Kumar</lastName>

json data,json object example,json data format,format json object,create json,json javascript example,json script example,simple json example
json tutorial for beginners
Difference between xml and json with example
There are following differences between XML and JSON
  • JSON format is lightweight over XML
  • JSON is recognized natively by JavaScript
  • JSON can contain integers, strings, lists, arrays. XML is just elements and nodes that need to be parsed into integers and so on before it can be consumed.
  • The most important disadvantage of JSON is that the format is very hard to read for humans, and that, of course, every single comma, quote, and bracket should be in exactly the correct place.
  • Serialization format for your data, JSON is smaller, lighter weight and generally faster than XML.
  • JSON is best for consumption of data in web applications from webservices for its size and ease of use, especially due to the built-in support in JavaScript.
  • Imagine the computation overhead for parsing an xml fragment compared to the instant lookup in JSON.
  • For configurations file XML is better choice to make because it more human readable.
  • A browser JSON is faster to serialize/deserialize as it’s simpler, more compact and more importantly natively supported.
  • XML is document-oriented. JSON is data-oriented. JSON can be mapped more easily to object-oriented systems.
  • XML and JSON both use Unicode.That help in support for internationalization.
  • JSON is a better data exchange format. XML is a better document exchange format.
  • XML requires translating the structure of the data into a document structure. This mapping can be complicated. JSON structures are based on arrays and records. That is what data is made of. XML structures are based on elements (which can be nested), attributes (which cannot), raw content text, entities, DTDs, and other meta structures.

    JSON JavaScript Example

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %> 
    <!DOCTYPE html> 
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>json object example</title>
            var text = '{"name":"John Johnson","street":"Oslo West 16","phone":"555 1234567"}';

            var obj = JSON.parse(text);

            alert(obj.name + ", " +
            obj.street + ", " +
        <form id="form1" runat="server">
                <h2>JSON Object Creation in JavaScript</h2>
    JSON Data Format - Simple Example Reviewed by Ravi Kumar on 5:58 PM Rating: 5

    No comments:

    All Rights Reserved by Etechpulse © 2012 - 2017

    Contact Form


    Email *

    Message *

    Powered by Blogger.