Copy link to clipboard
Copied
This is my Json :
{"MatchOnCourt":{"MatchID":"42959157","Tournament":"Ystad, Singles Qualifying, M-ITF-SWE-03A","P1Name":"ROBIN","P1Surname":"THOUR","P2Name":"OLLE","P2Surname":"NOLTORP","NOC1":"\u0026#160;","NOC2":"\u0026#160;","Score1":"0","Score2":"0","P1s1":"3","P1s2":"0","P1s3":"\u0026#160;","P2s1":"6","P2s2":"1","P2s3":"\u0026#160;","Serve":"1","Time":"00:49:59","Status":"SECOND_SET","CourtID":1,"Sponsor":null,"TournamentGroupID":777,"CourtName":"Court 4","Custom":null,"Info":"Break [T2] (double fault)","SRadarTournamentID":135793,"SRadarCategory":"ITF Men","Order":1}}
Code:
var that = this;
this.json = {};
this.loadJson = function(url)
{
var queue = new createjs.LoadQueue(true);
queue.on("fileload", that.onJsonLoaded, that);
queue.on("error", that.onJsonLoadError, that);
queue.loadFile({id:"json", src:url});
}
this.onJsonLoaded = function(e)
{
that.json = e.target.getResult("json");
console.log(that.json)
var jMat = that.json.MatchOnCourt;
console.log("0 +++++ " + jMat.Time)
}
this.onJsonLoadError = function(e)
{
console.log(e);
}
this.loadJson(URL);
What i am trying to do is to read the value time, i can load the Json (beacuse the firs console.log write my all the json file...) but i can not get "Time" value. What am i doing wrong?
Thanks
Copy link to clipboard
Copied
I find the problem.... i missed parsing to Json ... ( var jMat = JSON.parse(that.json); )
stupid error...
Copy link to clipboard
Copied
for others, this may make more sense:
{
"data":
[
{"id":"1","name":"John Deo","class":"Four5",
"mark":"75","sex":"male"},
{"id":"2","name":"Max Ruin","class":"Three5",
"mark":"85","sex":"male"},
{"id":"3","name":"Arnold","class":"Three5",
"mark":"55","sex":"male"},
{"id":"4","name":"Krish Star","class":"Four5",
"mark":"60","sex":"male"}
]
}