Hello I have JSON structured like this, and I need to iterate over the items
[
{
"name": "About You",
"questions": [
{
"questionText": "What is your surname?",
"answers": [
{
"text": "Thomas"
}
]
},
{
"questionText": "Where do you work?",
"answers": [
{
"text": "Finance"
}
]
},
]
},
{
"name": "About Family",
"questions": [
{
"questionText": "Childeren",
"answers": [
{
"text": "Yes"
}
]
},
{
"questionText": "Married",
"answers": [
{
"text": "No"
}
]
},
]
},
{
"name": "Travel",
"questions": [
{
"questionText": "Do you travel a lot?",
"answers": [
{
"text": "Yes"
}
]
}
]
}
]
I started with this code but I don't know how to show all the nested items. Should I use another map function? I would like to have format that will show table with questionTexts and answers text
{details.map((detail, i) => (
<div key={i}>
<div>{detail.name}</div>
<div>{detail.questions ? detail.questions[0].questionText : ''}</div>
<div>{detail.questions ? detail.questions[0].answers[0].text : ''}</div>
</div>
)
)}
thank you
.mapdetail.namewould be better.