这个json有什么问题:
{ "items" : [ {"timestamp":"1372964400","value":"1","nid":"545500","platform":"-1"},{"timestamp":"1373666400","value":"2","nid":"593141","platform":"-1"},{"timestamp":"1371398400","value":"1","nid":"34872","platform":"-1"},{"timestamp":"1374238800","value":"2","nid":"59251","platform":"-1"},{"timestamp":"1371902400","value":"1","nid":"79534","platform":"-1"},{"timestamp":"1373425200","value":"1","nid":"583657","platform":"-1"},{"timestamp":"1376251200","value":"4","nid":"701275","platform":"-1"},{"timestamp":"1371330000","value":"1","nid":"59251","platform":"-1"},{"timestamp":"1372183200","value":"1","nid":"81447","platform":"-1"},{"timestamp":"1372348800","value":"2","nid":"83560","platform":"-1"},{"timestamp":"1373162400","value":"1","nid":"583657","platform":"-1"},{"timestamp":"1374174000","value":"2","nid":"607389","platform":"-1"},{"timestamp":"1371834000","value":"2","nid":"79534","platform":"-1"},{"timestamp":"1372723200","value":"1","nid":"190555","platform":"-1"},{"timestamp":"1373385600","value":"2","nid":"590502","platform":"-1"},{"timestamp":"1375855200","value":"1","nid":"697831","platform":"-1"},{"timestamp":"1372312800","value":"1","nid":"81447","platform":"-1"},{"timestamp":"1373047200","value":"2","nid":"545517","platform":"-1"},{"timestamp":"1373929200","value":"3","nid":"605563","platform":"-1"},{"timestamp":"1375462800","value":"1","nid":"647466","platform":"-1"},{"timestamp":"1376434800","value":"5","nid":"704771","platform":"-1"},{"timestamp":"1371722400","value":"1","nid":"79534","platform":"-1"},{"timestamp":"1372240800","value":"1","nid":"82257","platform":"-1"},{"timestamp":"1372687200","value":"1","nid":"190555","platform":"-1"},{"timestamp":"1373367600","value":"1","nid":"590502","platform":"-1"},{"timestamp":"1374634800","value":"1","nid":"610377","platform":"-1"},{"timestamp":"1375812000","value":"1","nid":"697482","platform":"-1"},{"timestamp":"1372129200","value":"1","nid":"81157","platform":"-1"},{"timestamp":"1372287600","value":"1","nid":"79568","platform":"-1"},{"timestamp":"1372989600","value":"1","nid":"40191","platform":"-1"},{"timestamp":"1373788800","value":"1","nid":"545500","platform":"-1"},{"timestamp":"1375376400","value":"1","nid":"646893","platform":"-1"},{"timestamp":"1376420400","value":"1","nid":"704624","platform":"-1"},{"timestamp":"1371423600","value":"1","nid":"59251","platform":"-1"},{"timestamp":"1372230000","value":"7","nid":"81447","platform":"-1"},{"timestamp":"1372413600","value":"1","nid":"118275","platform":"-1"},{"timestamp":"1373306400","value":"5","nid":"590502","platform":"-1"},{"timestamp":"1374264000","value":"1","nid":"59251","platform":"-1"},{"timestamp":"1371960000","value":"1","nid":"79568","platform":"-1"},{"timestamp":"1372924800","value":"1","nid":"82456","platform":"-1"},{"timestamp":"1373558400","value":"3","nid":"590502","platform":"-1"},{"timestamp":"1375092000","value":"1","nid":"545500","platform":"-1"},{"timestamp":"1376280000","value":"1","nid":"701529","platform":"-1"},{"timestamp":"1370044800","value":"1","nid":"68566","platform":"-1"},{"timestamp":"1371380400","value":"1","nid":"59251","platform":"-1"},{"timestamp":"1372183200","value":"3","nid":"81457","platform":"-1"},{"timestamp":"1372352400","value":"1","nid":"83613","platform":"-1"},{"timestamp":"1373194800","value":"1","nid":"59251","platform":"-1"},{"timestamp":"1375689600","value":"1","nid":"687547","platform":"-1"},{"timestamp":"1371902400","value":"2","nid":"59251","platform":"-1"},{"timestamp":"1372762800","value":"1","nid":"212931","platform":"-1"},{"timestamp":"1375977600","value":"1","nid":"545500","platform":"-1"},{"timestamp":"1371322800","value":"2","nid":"59251","platform":"-1"},{"timestamp":"1372179600","value":"1","nid":"81457","platform":"-1"},{"timestamp":"1372345200","value":"2","nid":"83560","platform":"-1"},{"timestamp":"1373068800","value":"1","nid":"545517","platform":"-1"},{"timestamp":"1374163200","value":"1","nid":"607389","platform":"-1"},{"timestamp":"1375470000","value":"1","nid":"647526","platform":"-1"},{"timestamp":"1376460000","value":"1","nid":"705149","platform":"-1"},{"timestamp":"1370278800","value":"1","nid":"57508","platform":"-1"},{"timestamp":"1371765600","value":"2","nid":"79568","platform":"-1"},{"timestamp":"1372690800","value":"1","nid":"212147","platform":"-1"},{"timestamp":"1373382000","value":"9","nid":"590502","platform":"-1"},{"timestamp":"1374674400","value":"1","nid":"545500","platform":"-1"},{"timestamp":"1375819200","value":"1","nid":"697482","platform":"-1"},{"timestamp":"1371132000","value":"1","nid":"76647","platform":"-1"},{"timestamp":"1372143600","value":"1","nid":"81209","platform":"-1"},{"timestamp":"1372302000","value":"1","nid":"59251","platform":"-1"},{"timestamp":"1373036400","value":"1","nid":"545500","platform":"-1"},{"timestamp":"1373886000","value":"1","nid":"59251","platform":"-1"},{"timestamp":"1375380000","value":"1","nid":"646893","platform":"-1"},{"timestamp":"1376427600","value":"1","nid":"704735","platform":"-1"},{"timestamp":"1370260800","value":"3","nid":"68984","platform":"-1"},{"timestamp":"1372240800","value":"1","nid":"82162","platform":"-1"},{"timestamp":"1372428000","value":"1","nid":"154915","platform":"-1"},{"timestamp":"1373364000","value":"6","nid":"590502","platform":"-1"},{"timestamp":"1374606000","value":"1","nid":"610377","platform":"-1"}] }
在此字符串上运行json_decode时,php返回null。
我已经检查过每个在线php json_decoder并且他们成功解码了它。
我也试过json_decode($json, TRUE);
,但调用也返回NULL
我在PHP版本 PHP 5.5.1-2 + debphp.org~prelension + 2
我已经检查了json_last_error_msg()
要说的内容并返回了:
对象属性名称分隔符':'预期
答案 0 :(得分:1)
我不知道你为什么会收到这个错误,但它对我来说很好。 PHP v5.3.8
$json = '{ "items" : [ {"timestamp":"1372964400","value":"1","nid":"545500","platform":"-1"},{"timestamp":"1373666400","value":"2","nid":"593141","platform":"-1"},{"timestamp":"1371398400","value":"1","nid":"34872","platform":"-1"},{"timestamp":"1374238800","value":"2","nid":"59251","platform":"-1"},{"timestamp":"1371902400","value":"1","nid":"79534","platform":"-1"},{"timestamp":"1373425200","value":"1","nid":"583657","platform":"-1"},{"timestamp":"1376251200","value":"4","nid":"701275","platform":"-1"},{"timestamp":"1371330000","value":"1","nid":"59251","platform":"-1"},{"timestamp":"1372183200","value":"1","nid":"81447","platform":"-1"},{"timestamp":"1372348800","value":"2","nid":"83560","platform":"-1"},{"timestamp":"1373162400","value":"1","nid":"583657","platform":"-1"},{"timestamp":"1374174000","value":"2","nid":"607389","platform":"-1"},{"timestamp":"1371834000","value":"2","nid":"79534","platform":"-1"},{"timestamp":"1372723200","value":"1","nid":"190555","platform":"-1"},{"timestamp":"1373385600","value":"2","nid":"590502","platform":"-1"},{"timestamp":"1375855200","value":"1","nid":"697831","platform":"-1"},{"timestamp":"1372312800","value":"1","nid":"81447","platform":"-1"},{"timestamp":"1373047200","value":"2","nid":"545517","platform":"-1"},{"timestamp":"1373929200","value":"3","nid":"605563","platform":"-1"},{"timestamp":"1375462800","value":"1","nid":"647466","platform":"-1"},{"timestamp":"1376434800","value":"5","nid":"704771","platform":"-1"},{"timestamp":"1371722400","value":"1","nid":"79534","platform":"-1"},{"timestamp":"1372240800","value":"1","nid":"82257","platform":"-1"},{"timestamp":"1372687200","value":"1","nid":"190555","platform":"-1"},{"timestamp":"1373367600","value":"1","nid":"590502","platform":"-1"},{"timestamp":"1374634800","value":"1","nid":"610377","platform":"-1"},{"timestamp":"1375812000","value":"1","nid":"697482","platform":"-1"},{"timestamp":"1372129200","value":"1","nid":"81157","platform":"-1"},{"timestamp":"1372287600","value":"1","nid":"79568","platform":"-1"},{"timestamp":"1372989600","value":"1","nid":"40191","platform":"-1"},{"timestamp":"1373788800","value":"1","nid":"545500","platform":"-1"},{"timestamp":"1375376400","value":"1","nid":"646893","platform":"-1"},{"timestamp":"1376420400","value":"1","nid":"704624","platform":"-1"},{"timestamp":"1371423600","value":"1","nid":"59251","platform":"-1"},{"timestamp":"1372230000","value":"7","nid":"81447","platform":"-1"},{"timestamp":"1372413600","value":"1","nid":"118275","platform":"-1"},{"timestamp":"1373306400","value":"5","nid":"590502","platform":"-1"},{"timestamp":"1374264000","value":"1","nid":"59251","platform":"-1"},{"timestamp":"1371960000","value":"1","nid":"79568","platform":"-1"},{"timestamp":"1372924800","value":"1","nid":"82456","platform":"-1"},{"timestamp":"1373558400","value":"3","nid":"590502","platform":"-1"},{"timestamp":"1375092000","value":"1","nid":"545500","platform":"-1"},{"timestamp":"1376280000","value":"1","nid":"701529","platform":"-1"},{"timestamp":"1370044800","value":"1","nid":"68566","platform":"-1"},{"timestamp":"1371380400","value":"1","nid":"59251","platform":"-1"},{"timestamp":"1372183200","value":"3","nid":"81457","platform":"-1"},{"timestamp":"1372352400","value":"1","nid":"83613","platform":"-1"},{"timestamp":"1373194800","value":"1","nid":"59251","platform":"-1"},{"timestamp":"1375689600","value":"1","nid":"687547","platform":"-1"},{"timestamp":"1371902400","value":"2","nid":"59251","platform":"-1"},{"timestamp":"1372762800","value":"1","nid":"212931","platform":"-1"},{"timestamp":"1375977600","value":"1","nid":"545500","platform":"-1"},{"timestamp":"1371322800","value":"2","nid":"59251","platform":"-1"},{"timestamp":"1372179600","value":"1","nid":"81457","platform":"-1"},{"timestamp":"1372345200","value":"2","nid":"83560","platform":"-1"},{"timestamp":"1373068800","value":"1","nid":"545517","platform":"-1"},{"timestamp":"1374163200","value":"1","nid":"607389","platform":"-1"},{"timestamp":"1375470000","value":"1","nid":"647526","platform":"-1"},{"timestamp":"1376460000","value":"1","nid":"705149","platform":"-1"},{"timestamp":"1370278800","value":"1","nid":"57508","platform":"-1"},{"timestamp":"1371765600","value":"2","nid":"79568","platform":"-1"},{"timestamp":"1372690800","value":"1","nid":"212147","platform":"-1"},{"timestamp":"1373382000","value":"9","nid":"590502","platform":"-1"},{"timestamp":"1374674400","value":"1","nid":"545500","platform":"-1"},{"timestamp":"1375819200","value":"1","nid":"697482","platform":"-1"},{"timestamp":"1371132000","value":"1","nid":"76647","platform":"-1"},{"timestamp":"1372143600","value":"1","nid":"81209","platform":"-1"},{"timestamp":"1372302000","value":"1","nid":"59251","platform":"-1"},{"timestamp":"1373036400","value":"1","nid":"545500","platform":"-1"},{"timestamp":"1373886000","value":"1","nid":"59251","platform":"-1"},{"timestamp":"1375380000","value":"1","nid":"646893","platform":"-1"},{"timestamp":"1376427600","value":"1","nid":"704735","platform":"-1"},{"timestamp":"1370260800","value":"3","nid":"68984","platform":"-1"},{"timestamp":"1372240800","value":"1","nid":"82162","platform":"-1"},{"timestamp":"1372428000","value":"1","nid":"154915","platform":"-1"},{"timestamp":"1373364000","value":"6","nid":"590502","platform":"-1"},{"timestamp":"1374606000","value":"1","nid":"610377","platform":"-1"}] }';
var_dump(json_decode($json));