I am looking to manipulate the values of a nested object using JavaScript. The structure of the object is outlined below.
let jsonObj = {
"service":[
{
"name":"restservice",
"device":"xr-1",
"interface-port":"0/0/2/3",
"interface-description":"uBot testing for NSO REST",
"addr":"10.10.1.3/24",
"mtu":1024
}
],
"person": {
"male": {
"name": "infinitbility"
},
"female": {
"name": "aguidehub",
"address": {
"city": "bbsr",
"pin": "752109"
}
}
}
}
In the above example, I want to find and replace specific values within the nested object. Specifically, I need to locate all instances of the key name
and update the value to BBSR
. With three occurrences of the name
key in the object, I will use JavaScript to perform these replacements.