I am trying to replace a specific value from the JSON file. let's suppose given below is my JSON data
sample.json
let sample={
"yuiwedw":{
"id":"yuiwedw",
"loc": "ar",
"body":{
"data":"we got this",
"loc":"ar",
"system":{
"fname":"admin",
"lname":"admin",
"details":[
{
"id":"Admin_01",
"loc":"ar"
},
{
"id":"Admin_02",
"loc":"ar"
}
]
}
}
},
"hbjds324":{
"id":"hbjds324",
"loc": "ar",
"body":{
"data":"testing",
"loc":"ar",
"system":{
"fname":"public",
"lname":"servent",
"details":[
{
"id":"public_01",
"loc":"ar"
}
],
"Available":true,
"loc":"ar"
}
}
}
}
for (const value of Object.values(
sample )) {
value.loc = "en";
}
console.log(sample);
So I want to replace all the loc values which is ar with the en I can replace the value which at the first level but how to change all the loc value which is present at a different level.