I need to add an attribute which doesn't exist in the current JSON. The json object looks like below.
var jsonObj = {
result : OK,
data : []
};
And I want to add temperature inside 'data'. I could do it like below.
jsonObj.data.push( {temperature : {}} );
And then, I want to add 'home', 'work' inside 'temperature'. The result would be like below.
{
result : OK,
data : [
{ temperature : {
home : 24,
work : 20 } }
]
};
How could I do this? I succeeded to insert 'temperature' inside 'data', but couldn't add 'home' & 'work' inside temperature. There could be more inside the 'temperature' so it needs to be enclosed with {}.