This is stupid but i am missing something and could not reach the conclusion. I am trying to initialize a JSON Array and trying to add JSON Objects to it run time. For an exampl
You can init a new json object like this:
var jsonObj = {};
jsonObj.employees = [];
jsonObj.employees.push({"firstName":"Waqar", "lastName":"Alamgir"});
or add data in existance like this:
var jsonObj = {
"employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]
};
jsonObj.employees.push({"firstName":"Waqar", "lastName":"Alamgir"});
console.log(jsonObj);