I have the following variable holding a json array.
let requestJson = '{ "data": [ { "type": "Type1", "value": "MyValue" } ] }';
I would like to add a property called "Id" to the above object inside data array. I expect to get something like;
{ "data": [ { "type": "Type1", "value": "MyValue", "id": "123" } ] }
How can I achieve this? I tried the following:
requestJson["data"][0]["id"] = '123';
But when I print requestJson["data"]
I'm getting undefined
. Would appreciate any help in appending the "Id" attribute to the object inside the array above. Thanks in advance.