JSFiddle - React, Tailwind, and code Playground
JavaScript
json={"1": {
"id": 1,
"name": "lola",
"phones": [{
"mobile": "xxx",
"home": "xxx",
"work": "xxx",
"hardwares": [{
"provider": "samsung",
"model": "galaxy S5"
}, {
"provider": "apple",
"model": "iphone 6"
}]
}]
}};
json["1"].phones.push({
mobile: "xxxxx",
home: "xxxxx",
work: "xxxxx",
"hardwares": []
});
json["1"].phones[0]['hardwares'].push({
provider: "provider 0",
model: "model 0",
});
json["1"].phones[1]['hardwares'].push({
provider: "provider 1",
model: "model 1",
});
console.log( JSON.stringify(json) );