When constructing a JSON array object using two different arrays, I noticed that the value of the last iterated value is being assigned to every element in the array. Specifically, for the serial number element, only the last iterated value is being displayed. Is there something crucial that I might be overlooking?
for (z = 0; z < postAdvancedAddressCheckRequest.addressCheck.energyQuoteAddress.electricityMeter.length; z++) {
for (i = 0; i < ecoesGetTechnicalDetailsByMpanResponse.Results[0].UtilityMatches.length; i++) {
for (j = 0; j < ecoesGetTechnicalDetailsByMpanResponse.Results[0].UtilityMatches[i].Meters.length; j++) {
for (k = 0; k < ecoesGetTechnicalDetailsByMpanResponse.Results[0].UtilityMatches[i].Meters[j].MeterDetails.length; k++) {
if (ecoesGetTechnicalDetailsByMpanResponse.Results[0].UtilityMatches[i].Meters[j].MeterDetails[k].Key === "meter_serial_number") {
var serialNumber1 = ecoesGetTechnicalDetailsByMpanResponse.Results[0].UtilityMatches[i].Meters[j].MeterDetails[k].Value;
}
}
electricityMeterObject = {
"Check": true,
"serialNumber": serialNumber1
}
electricityArray.push(electricityMeterObject);
}
}
}