My JSON object data:
{
"title": "aa",
"desc": ["i", "j", "k"],
"cnt": {
"head": "bb",
"main": {
"num1": {
"time1": "mm",
"time2": "kk"
},
"num2": "dd"
}
}
}
My question is: How do I translate the above JSON object to the below by using JavaScript?
{
"title": "aa",
"desc": ["i", "j", "k"],
"cnt_head": "bb",
"cnt_main_num1_time1": "mm",
"cnt_main_num1_time2": "kk",
"cnt_main_num2": "dd"
}
I tried using for(i in obj) {....}
but failed!
Please help!