JSON Introduction

JSONJSON ObjectJSON Type

What is JSON?

JSON (JavaScript Object Notation) is a data interchange format that mainly uses stateless applications or features development as an alternative to XML, YAML. It is a subset of JavaScript, which converts JSON data to native JS objects.

JSON mainly creat in two structure

  1. Collection of name value pairs - It is similar to structure in C/C++. Each element is considered as an object or array or hash table or record etc.
    { "browsertool" : "JSON Diff Checker", "datatype" : "text/plain" , "pagenumber" : 10 }

  2. List of values - Usually it is recognized as an array or sequence or list.
    [
    	{ "webtool" : "JSON Formatter", "datatype" : "text/json" },
    	{ "webtool" : "XML Formatter ", "datatype" : "text/xml" },
    	{ "webtool" : "CSV Formatter ", "datatype" : "text/plain" }
    ]

Example of different form of JSON

  1. Object - Object is key (name) / value pair.
    {  "browsertool" : "JSON Minifier", "datatype" : "text/plain" , "pagenumber" : 10 }

  2. Array - Array is a list of the same data type values.
    [ "JSON", "CSV", "XML", "JAVA"]

  3. Value - In JSON, value can use object or array or string or number or true or false or null.
    {
        "browsertool": {
            "toolname": "JSON Minifier",
            "datatype": "text/plain",
            "pagenumber": 10
        },
        "dataarray" : [ 10, 20, 100]
    }

  4. String - In JSON String, any character can be use inside of double quotes. Ex. ' " ' characters ' " '
    {"datatype" : "application/json"}

  5. Number - Integer, fraction, exponent can be used in JSON, different forms like hexadecimal or octal can pass as a string.
    {"cout" : 22, "fraction" : 22.5}

  6. Whitespace - " ", \n (linefeed), \r (carriage return), \t (horizontal tab) can be use between any key value pair.
    {"cout" : 22 ,
                       "fraction" :
        22.5}


JSON is a simple text data format as well as it is not dependent on any language. Many programming languages readily available JSON data processors and generators.

Credits


json.org - Introducing JSON Standard