Photo Gallery

Sunday, September 24, 2017

JSON with an Example

In this post, we will see about Json with an example.
What is JSON ?
It stands for Java Script Object Notation and it's kind of data exchange format. It's used to communicate between Javascript and server technology like ASP.

Why JSON?
Easy for human to Rd/WR better than XML.
Language independent and lightweight.
Parsing is easier than XML.

Syntax : Name / Value Pair

objectJson : {"EmployeeName": 1001}

If we want to parse this object into Javascript object, then we can use JSON.Parse method.

var obj=JSON.Parse (objectJson );

so, value become object of JavaScript.

obj.EmployeeName

Important Note: JSON value can be object or Arrays. [x,y,z]

JSON Example

{

   "title": "Jokes",

   "JokesCount":2,

   "JokesList":[

                    {

                         "Id": 1,

                         "Jokes": "I dressed my dog as a cat for Halloween...",

                         "Category": "Fun"

                    },

                    {

                          "Id": 2,

                          "Jokes": "A scientist tells a pharmacist...",

                          "Category": "Misc"

                    }

            ]

}



This above example shows the messages formatted using JSON.



If you have any questions, post here. Also, provide your valuable suggestions and thoughts in form of comments in the section below.

Thank you !!!


No comments:

Post a Comment