如何会有错呢,简单的json读取
程序员文章站
2022-04-16 13:08:31
...
怎么会有错呢,简单的json读取
$pingluninfo = {
"title":"123",
"url":"http://localhost/?p=9",
"ttime":1401327899094,
"sourceid":"9",
"parentid":"0",
"categoryid":"",
"ownerid":"",
"metadata":"",
"comments":[
{
"cmtid":"358",
"ctime":1401327899094,
"content":"2013年8月1日18:36:29 O(∩_∩)O~",
"replyid":"0",
"user":{
"userid":"1",
"nickname":"admin",
"usericon":"",
"userurl":"",
"usermetadata":{
"area": "北京市",
"gender": "1",
"kk": "",
"level": 1
}
},
"ip":"127.0.0.1",
"useragent":"Mozilla/5.0 (Windows NT 6.1; rv:22.0) Gecko/20100101 Firefox/22.0",
"channeltype":"1",
"from":"",
"spcount":"",
"opcount":"",
"attachment":[
{
"type":1,
"desc":"",
"url":"http://img.sohu.itc/xxxx"
}
]
}
]
}
EOT;
$pingluninfo = json_decode($pingluninfo, true);
if(!$pingluninfo) {
die('错误的数据格式');
}
?>
总是输出 错误的数据格式
------解决思路----------------------
$pingluninfo = {
"title":"123",
"url":"http://localhost/?p=9",
"ttime":1401327899094,
"sourceid":"9",
"parentid":"0",
"categoryid":"",
"ownerid":"",
"metadata":"",
"comments":[
{
"cmtid":"358",
"ctime":1401327899094,
"content":"2013年8月1日18:36:29 O(∩_∩)O~",
"replyid":"0",
"user":{
"userid":"1",
"nickname":"admin",
"usericon":"",
"userurl":"",
"usermetadata":{
"area": "北京市",
"gender": "1",
"kk": "",
"level": 1
}
},
"ip":"127.0.0.1",
"useragent":"Mozilla/5.0 (Windows NT 6.1; rv:22.0) Gecko/20100101 Firefox/22.0",
"channeltype":"1",
"from":"",
"spcount":"",
"opcount":"",
"attachment":[
{
"type":1,
"desc":"",
"url":"http://img.sohu.itc/xxxx"
}
]
}
]
}
EOT;
$pingluninfo = json_decode($pingluninfo, true);
if(!$pingluninfo) {
die('错误的数据格式');
}
?>
总是输出 错误的数据格式
------解决思路----------------------
$pingluninfo = {
"title":"123",
"url":"http://localhost/?p=9",
"ttime":1401327899094,
"sourceid":"9",
"parentid":"0",
"categoryid":"",
"ownerid":"",
"metadata":"",
"comments":[
{
"cmtid":"358",
"ctime":1401327899094,
"content":"2013年8月1日18:36:29 O(∩_∩)O~",
"replyid":"0",
"user":{
"userid":"1",
"nickname":"admin",
"usericon":"",
"userurl":"",
"usermetadata":{
"area": "北京市",
"gender": "1",相关文章
相关视频
上一篇: python中的%是什么意思
下一篇: python安装后怎么启用