如何会有错呢,简单的json读取

WBOY
发布: 2016-06-13 12:08:14
原创
867 人浏览过

怎么会有错呢,简单的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('错误的数据格式');
}
?>
总是输出 错误的数据格式
------解决思路----------------------

<br><?php  <br />$pingluninfo = {<br>    "title":"123",<br>    "url":"http://localhost/?p=9",<br>    "ttime":1401327899094,<br>    "sourceid":"9",<br>    "parentid":"0",<br>    "categoryid":"",<br>    "ownerid":"",<br>    "metadata":"",<br>    "comments":[<br>        {<br>            "cmtid":"358",<br>            "ctime":1401327899094,<br>            "content":"2013年8月1日18:36:29 O(∩_∩)O~",<br>            "replyid":"0",<br>            "user":{<br>                "userid":"1",<br>                "nickname":"admin",<br>                "usericon":"",<br>                "userurl":"",<br>                "usermetadata":{<br>                    "area": "北京市",<br>                    "gender": "1",<div class="clear">
                 
              
              
        
            </div>
登录后复制
相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板