I have a JSON file that has nested arrays but just can't figure it out how to map nested arrays or in other words how to get / show only first or second array.
Example:
My JSON file:
[
{
"id": 1,
"title": "Video 1",
"video_leght": "00:50:00",
"date": "20.05.2010",
"questions": [
{
"id": 1,
"question": "Question 1 ",
"url": "Link"
},
{
"id": 2,
"question": "Question 2",
"url": "Link"
},
{
"id": 3,
"question": "Question 3",
"url": "Link"
}
]
},
{
"id": 2,
"title": "Video 2",
"video_leght": "01:00:00",
"date": "14.07.2016",
"questions":[
{
"id": 1,
"question": "Question 1 ",
"url": "Link"
},
{
"id": 2,
"question": "Question 2",
"url": "Link"
},
{
"id": 3,
"question": "Question 3",
"url": "Link"
}
]
}
]
For example, I want to show only the questions from Video 2. So I would have i.e. 3x divs - in each div one question of Video 2.
I'm new to React and JavaScript so please don't mind if this is something simple to solve.
Thanks in advance!
What I have tried:
<div>
{DataList.map((ListItem, index) => {
return (
<div key={index}>
<h3>{ListItem.id[2].question)}</h3>
</div>
);
})}
</div>