I want to update field in json. My field is selectedCIID, this field is inside the some object with some hierarchy,
rows->panels->target->selectedCIId,
var dashboard = results.dashboard;
var dashboardJson = angular.fromJson(dashboard);
//dashboardJson.rows //dashboardJson.rows[0].panels
var j;
for(i=0; i<=dashboardJson.rows; i++){
for(j=0;)
dashboardJson.rows[i].panels
dashboardJson.rows[0].panels[0].targets[0].selectedCIID = ci;
//dashboardJson.rows[0].panels[0].targets[0].selectedCIID
}
JSON:
{
"rows": [{
"title": " row 1",
"panels": [{
"targets": [{
"selectedCIID": "5856742957ce424b8db6cfb309b6b013",
"series": ""
}]
}]
}, {
"title": "row 2",
"panels": [{
"targets": [{
"selectedCIID": "5856742957ce424b8db6cfb309b6b013",
"series": ""
}]
}, {
"targets": [{
"selectedCIID": "5856742957ce424b8db6cfb309b6b013",
"series": ""
}]
}]
}]
}
Code above is just dummy code for showing my approach. I can do this using native JS code. for loop.
But if I can use lodash for iterating this object _each or something it will be fine.
Or
How can I write the code to find selectedCIID inside panels wherever this field is coming updated with the my variable.
I want to update "selectedCIID" field. Please help me..