Saturday 22 December 2018

JAVASCRIPT JSON

JAVASCRIPT JSON


  • JSON- JavaScript Object Notation
  • Which is  language independent.
  • Self-describing and easy to understand
  • Json is a format for storing and transporting data.
  • Which is often used when data is sent from a server to a web page.
  • json file type is - .json 
  • json mime type is -  application/json
  • Exchanging data
               -Sending data
               -Receiving data

               -Storing data
      


Syntax of JSON

  •   Name/value pairs
               "name":"value"
  •   Every data will separate by commas
                "name1":"value1"  ,  "name2":"value2" , "name3":"value3"
  •   Objects for curly bracket
               {"name1":"value1"  ,  "name2":"value2" , "name3":"value3" }
  •   Arrays for square bracket

               ["value1" , "value2" , "value3"]



    Different between syntax of javascript and JSON

    In javascript -  name: "value" / name: 'value'

    In JSON  -  "name": "value" / "name": 'value'


    JSON object

    object syntax -  {"name1":"value1"  ,  "age1": 11 };

    accessing object value

    eg1-

    var obj = {"name1":"value1"  ,  "age1": 11 };
    var out = obj.name1;
    document.getElementById().innerHTML=out;

    eg2-

    var obj = {"name1":"value1"  ,  "age1": 11 };
    var out = obj["name1"];
    document.getElementById().innerHTML=out;

    0 comments:

    Post a Comment