Thursday, May 10, 2018

How do you create a JSON object?

You go by definition of a JSON Object. JSON Object components are placed under curly braces as shown here.

{"name1":"value1","name2":"value2","name3":"value3"}

Here is an example:

var JSONObj = {"Fname":"Jay","LName":"Krishna","Hobby":"Blogging"};

JSON object consists of name/value pairs separated by commas.

In the above names are:
Fname, LName and Hobby

The corresponding values are:
Jay, Krishna and Blogging

Here is an HTML file that writes the values of a JSON object to the browser.

You can upload it to your website (perhaps IIS's Localhost). When you browse to it you get this response.



For a more detailed article go here:

No comments: