I've been playing with json objects & using ReactJS. One of the json object represented by variable 'res'. How do I convert 'res' into 'b'. I'm also getting my json object 'res' from an api.
I've reciprocated my problem over this link: https://codesandbox.io/s/epic-leaf-sznhx?file=/src/App.js
const [res, setResult] = useState();
useEffect(() => {
(async () => {
axios.get("https://corona.lmao.ninja/v2/countries").then(response => {
setResult(response.data);
});
})();
}, []);
How do I convert this:
const a =
{
"menu_1": {
"id": "1",
"menuitem": [{
"value": "0",
"onclick": "0()"
}, {
"value": "0",
"onclick": "0()"
}]
},
"menu_2": {
"id": "2",
"menuitem": [{
"value": "2",
"onclick": "2()"
}]
}
}
into this json object:
const b =
{
"popup": {
"menuitem": [
{
"value": "0",
"onclick": "0()"
},
{
"value": "0",
"onclick": "0()"
},
{
"value": "2",
"onclick": "2()"
}
]
}
}