I need to search and replace value from a nested object using javascript. I am explaining the object 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 nested object I need to search the key and replace the value. Here my requirement is in the entire object it will search for the key name
and where ever it is found it will replace the value as BBSR
. In the above case there are 3 place where name
key is present so I need to replace the value accordingly using Javascript.