Thursday, August 21, 2014

Previous Interview Question Next Interview Question
Home

Difference Between JSON and Javascript Object Literal Notation

JSON [Javascript Object Notation] Vs Javascript Object Literal Notation


The main differences:
  • The keys must be strings (i.e. enclosed in double quotes ") in JSON.
  • The values can be either:
    • a string
    • a number
    • an (JSON) object
    • an array
    • true
    • false
    • null

JSON Example :



{

    "users": [
        {
            "id": 1,
            "websitename": "Webcodehelpers",
            "url": "www.webcodehelpers"
        },
        {
            "id": 2,
            "websitename": "SriSolutions",
            "url": "www.srisolutions.in"
        }
    ]
}

Javascript Object Literal Notation Example :


{ users: [ { id: "1", websitename: "Webcodehelpers", url: "www.webcodehelpers" }, { id: "2", websitename: "SriSolutions", url: "www.srisolutions.in" } ] }




Previous Interview Question Next Interview Question
Home

0 comments :

Post a Comment