I recently encountered a dynamic JSON object:
{
"SMSPhone": [
"SMS Phone Number is not valid"
],
"VoicePhone": [
"Voice Phone Number is not valid"
]
}
My goal is to extract the values as a comma-separated string. The challenge here is that I do not know the key names beforehand.
The desired output should be: SMS Phone Number is not valid, Voice Phone Number is not valid
This is the code snippet I attempted:
let res = JSON.parse(Jsondata);
res.forEach(element => {
console.log(element)
//logic
});
However, upon running this code, I encountered the following error: https://i.stack.imgur.com/vxsFQ.png