我想解析this JSON data to print on a fanpage I am working on。 如果你看看那个JSON链接,你会看到结构是[{key:value,key:value,key:value}]
。我最近学会了如何与一个稍微不同的结构是怎样的this JSON file,其中数据结构是{"identifier":[{key:value,value,value,value,value}{key:value,value...}]}
解析JSON与PHP阵列/对象混淆
这里是我的代码,我试图解析JSON(我试图约10的这种变化与爆炸的逗号太)
<?php
$json = file_get_contents('http://live.nhl.com/GameData/SeasonSchedule-20152016.json');
$json = json_decode($json, TRUE);
foreach($json as $d){
$estTime = $d['est'];
echo $estTime;
?>
正如我所说的,我有一些成功的做这个链接的JSON我的其他结构:
$json = file_get_contents('http://nhlwc.cdnak.neulion.com/fs1/nhl/league/playerstatsline/20152016/2/SJS/iphone/playerstatsline.json');
$json = json_decode($json, TRUE);
$skaterData = $json['skaterData'];
$goalieData = $json['goalieData'];
foreach($skaterData as $d){
$stats = explode(',', $d['data']);
$number = $stats[0];
$position = $stats[1];
$name = $stats[2];
$gp = $stats[3];
$goals = $stats[4];
$assists = $stats[5];
$points = $stats[6];
$plsmns = $stats[7];
$pim = $stats[8];
$shots = $stats[9];
$toi = $stats[10];
$pp = $stats[11];
$sh = $stats[12];
$gwg = $stats[13];
$ot = $stats[14];
编辑:JSON data successfully parsed
非常尴尬,我在整个过程中花费了很多时间在其他方面......无论如何谢谢。我使用记事本++ atm –
不言而喻它现在正在工作哈哈。对不起,浪费你的时间。请不要投票给我! [链接](http://52.4.65.161/final_project/schedule.php) –