How to create JSON Object from JavaScript?
Answered
How to create JSON Object from JavaScript?
Best answer
JSON objects can be created with JavaScript. Let us see various ways of creating JSON objects using JavaScript:
Creation of an empty Object:
var JSONObj = {};
Creation of new Object:
var JSONObj = new Object();
Creation of an object with attribute employeename with value in string, attribute age with numeric value. Attributes is accessed by using ‘.’ operator:
var JSONObj = { “employeename “:”James”, “age”:25 };