I have encountered a JSON structure that is causing me some trouble:
const help = [
{
"en": [
{
"test2": [
{
"title": "Naslov1",
"subtitle": "Podnaslov1",
"answers": [
{
"answer": "Odgovor 11"
},
{
"answer": "Odgovor 12"
}
]
}
],
"test1": [
{
"title": "Naslov2",
"subtitle": "Podnaslov2",
"answers": [
{
"answer": "Odgovor 21"
},
{
"answer": "Odgovor 22"
}
]
}
]
}
]
}
]
My goal is to filter this JSON by certain properties, specifically en and test2. The desired object structure I am aiming for is:
const newArray = [ {
"title": "Naslov1",
"subtitle": "Podnaslov1",
"answers": [
{
"answer": "Odgovor 11"
},
{
"answer": "Odgovor 12"
}
]
}]
I attempted to access the data using help.en.test2, but encountered an error: TypeError: Cannot read property 'test2' of undefined
If anyone has any insights on how I can properly remap this JSON, I would greatly appreciate the help. Thank you!