I'm creating a webpage which displays data which I have parsed from a JSON. I am using 2 JSON files. One I can parse with no problems however, the second I am struggling with.
I want to be able to parse the JSON looking for a specific object string and return all the other object strings within the same dictionary.
The layout of the JSON is:
{
"example":[
{
"Area":"Inside",
"Player":"1",
"Status":1,
"Start_Time":"2016-12-21",
"End_Time":"2016-12-22",
},
{
"Area":"Outside",
"Player":"1",
"Status":1,
"Start_Time":"2016-12-24",
"End_Time":"2016-12-25",
},
{
"Area":"Outside",
"Player":"2",
"Status":1,
"Start_Time":"2016-12-26",
"End_Time":"2016-12-28",
}
]
}
I want to say
if (player=="1") {//show ALL areas and start and end time}
//output should be something like: Area: Inside, Player: 1, Status: 1, Start_Time: 'Time', End_Time: 'Time', Area: Outside, Player: 1, Status: 1, Start_Time: 'Time', End_Time: 'Time'
I am trying to parse the JSON in javascript, this is how I am parsing the other JSON:
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var myObj = JSON.parse(this.responseText);
var dateTime = myObj.Date;
}
};
xmlhttp.open("GET", "http://web/server/file.json", true);
xmlhttp.send();
Any help is appreciated.