I’m new to Jquery and I have this json file look like this.
var json2 = {
"data": [
{
"cid": "Movie",
"id": "/en/MIB",
"topic": "Men In Black",
"audience": [
{
"userid": "100003914111287",
"Name" : "Sandi Tan",
"information": [
{
"category": "Athlete",
"source": "Didier Drogba"
},
{
"category": "Athlete",
"source": "Frank Lampard"
},
{
"category": "Professional sports team",
"source": "Chelsea Football Club"
},
{
"category": "favorite_teams",
"source": "Chelsea Football Club"
}
]
},
{
"userid": "100003914111287",
"Name": "Celia Tio",
"information": [
{
"category": "Athlete",
"source": "Didier Drogba"
},
{
"category": "Athlete",
"source": "Frank Lampard"
},
{
"category": "Professional sports team",
"source": "Chelsea Football Club"
},
{
"category": "favorite_teams",
"source": "Chelsea Football Club"
}
]
}
],
"type": "/soccer/football_team"
},
{
"id": "/en/Harry Potter",
"topic": "Harry Potter and the goblet of fire",
"audience": [
{
"userid": "100003914111287",
"Name": "Gibson Tay",
"information": [
{
"category": "Athlete",
"source": "Ryan Giggs"
},
{
"category": "Professional sports team",
"source": "Manchester United"
},
{
"category": "favorite_teams",
"source": "Manchester United"
}
],
"userid": "100003921730958"
},
{
"userid": "100003914111287",
"Name": "James Tan",
"information": [
{
"category": "Athlete",
"source": "Didier Drogba"
},
{
"category": "Athlete",
"source": "Frank Lampard"
},
{
"category": "Professional sports team",
"source": "Chelsea Football Club"
},
{
"category": "favorite_teams",
"source": "Chelsea Football Club"
}
]
}
],
"type": "/soccer/football_team"
},
{
"cid": "Movie",
"id": "/en/Iron Man",
"topic": "Iron Man",
"audience": [
{
"userid": "100003914111287",
"Name" : "Edmund Tan",
"information": [
{
"category": "Athlete",
"source": "Didier Drogba"
},
{
"category": "Athlete",
"source": "Frank Lampard"
},
{
"category": "Professional sports team",
"source": "Chelsea Football Club"
},
{
"category": "favorite_teams",
"source": "Chelsea Football Club"
}
]
},
],
"type": "/soccer/football_team"
}
]
};
How can I extract out the information. I wan only the topic name(e.g Men in black) and the person name (e.g “Sandi Tan”) and append into a table which looks like this:
**Men in Black, Iron man Harry Potter**
Sandi Tan Edmund Tan Gibson Tay
Celia Tio James tan
To get all names and topics you can do it like this with a loop
To append to table
Dynamically add to table