Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

JavaScript JSON

  • Difficulty Level : Medium
  • Last Updated : 06 Jun, 2018

What is JSON?
JSON or JavaScript Object Notation is a format for structuring data.

What is it used for?
Like XML, it is one of the way of formatting the data. Such format of data is used by web applications to communicate with each other.

Characteristics of JSON

  • It is Human-readable and writable.
  • It is light weight text based data interchange format which means, it is simpler to read and write when compared to XML.
  • Though it is derived from a subset of JavaScript, yet it is Language independent. Thus, the code for generating and parsing JSON data can be written in any other programming language.

JSON Syntax Rules
JSON syntax is derived from JavaScript object notation syntax:

  • Data is in name/value pairs

    { “name”:”Thanos” }

    Types of Values:
    Array: An associative array of values.
    Boolean: True or false.
    Number: An integer.
    Object: An associative array of key/value pairs.
    String: Several plain text characters which usually form a word.

  • Data is separated by commas

    { “name”:”Thanos”, “Occupation”:”Destroying half of humanity” }

  • Curly braces hold objects

    var person={ “name”:”Thanos”, “Occupation”:”Destroying half of humanity” }

    Here person is the object.

  • Square brackets hold arrays

    var person={ “name”:”Thanos”, “Occupation”:”Destroying half of humanity”,
    [“Can destroy anything with snap of his fingers”,
    “Damage resistance”, “Superhuman reflexes”] }

    Here person is the object and powers is an array.


    "Avengers": [
          "Name" : "Tony stark",
          "also known as" : "Iron man",
          "Abilities" : [ "Genius", "Billionaire",
                        "Playboy", "Philanthropist" ]
          "Name" : "Peter parker",
          "also known as" : "Spider man",
          "Abilities" : [ "Spider web", "Spidy sense" ]

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!