I am currently in the process of updating a single value (ElementStatus) within the multidimensional JSON file shown below.
BuildingID: 1521
BuildingName: "PEN LLOYD BUILDING"
BuildingNumber: "A"
ElementList: Array(15)
0: {ElementID: 114, SurveyTypeID: 3, Code: "M.01.01.01", ElementDescription: "M.01.01.01 Boilers/Plant", ElementStatus: "null"}
1: {ElementID: 115, SurveyTypeID: 3, Code: "M.01.01.02", ElementDescription: "M.01.01.02 Heat Emitters", ElementStatus: "null"}
2: {ElementID: 116, SurveyTypeID: 3, Code: "M.01.01.03", ElementDescription: "M.01.01.03 Distribution", ElementStatus: "completed"}
Below is the code snippet
var newData = JSON.parse(success);
const data1 = newData[0].results.recordset[0].ElementList;
//console.log(data1.toArray());
var array = JSON.parse(data1);
array.forEach(function(element){
if(element.ElementDescription == elementsName)
{
element.ElementStatus = "completed";
}
})
newData[0].results.recordset[0].ElementList = array;
Upon completion of the forEach loop, I am obtaining the ElementList in Array format. However, I require it in string format as it was previously.