Below is the information stored in a file called "fokontanys.json":
{
"vzdveg643": {
"lldistrict":"Ambilobe",
"id_province": 7,
"id": null
},
"vzvsdv5327": {
"lldistrict":"Ambilobe",
"id_province": 7,
"id": null
}
}
I am looking to replace the value of "null" for the "id" key with the respective object keys. I have successfully imported the json file:
let fokontanys = require("./fokontanys.json");
Within a foreach loop, I am making the necessary modifications:
Object.keys(fokontanys).forEach(function (fokontany) {
fokontanys[fokontany].ll_district=fokontanys[fokontany].lldistrict;
fokontanys[fokontany].id="????????????????";
delete fokontanys[fokontany].lldistrict;
newFokontanys[fokontany] = fokontanys[fokontany];
});
console.log(newFokontanys);
Is there a method to extract the object keys and assign them as the id values? I have been struggling to find a solution for this. Any assistance would be greatly appreciated.