Created
March 8, 2015 20:15
-
-
Save rackaam/da9277c8dfb763a70ebe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var o = JSON.parse('{"code": 0,"court": {"Set": { "1": { "A": 0, "B": 6 }, "2": { "A": 0, "B": 0 } }, "TeamA": "BEL", "NameA": "E.DOM", "ScoreA": "0", "Duration": "02:31", "Winner": null, "Tableau": "1/2-P", "Category": "SW", "Court": 6, "TeamB": "DEU", "NameB": "A.FUCHS", "ScoreB": "40", "Service": "B" }}'); | |
// Afficher nom de la team A | |
console.log(o.court.TeamA); | |
// Afficher le score de tous les sets | |
var sets = o.court.Set; | |
for(id in sets){ | |
console.log("Set " + id + " A:" + sets[id].A); | |
console.log("Set " + id + " B:" + sets[id].B); | |
} | |
// Verifier si un set existe : | |
var set = 3; | |
if(set in o.court.Set){ | |
console.log("Set " + set + " existe"); | |
}else{ | |
console.log("Set " + set + " n'existe pas"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
le texte en paramètre de JSON.parse est le résultat de la requête à l'api ;)