您好,欢迎访问一九零五行业门户网

怎么会有错呢,简单的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('错误的数据格式');
}
?>
总是输出 错误的数据格式
回复讨论(解决方案) 看着json 不对劲。
中文在json_encode 后不是这样的吧
1401327899094 [sourceid] => 9 [parentid] => 0 [categoryid] => [ownerid] => [metadata] => [comments] => array ( [0] => array ( [cmtid] => 358 [ctime] => 1401327899094 [content] => 2013年8月1日18:36:29 o(∩_∩)o~ [replyid] => 0 [user] => array ( [userid] => 1 [nickname] => admin [usericon] => [userurl] => [usermetadata] => array ( [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] => array ( [0] => array ( [type] => 1 [desc] => [url] => http://img.sohu.itc/xxxx ) ) ) ))

测试无误
请把引号补齐!
ttime:1401327899094, 应为 ttime:1401327899094,
其他类同
echo '';$pingluninfo = < http://localhost/?p=9 [ttime] => 1401327899094 [sourceid] => 9 [parentid] => 0 [categoryid] => [ownerid] => [metadata] => [comments] => array ( [0] => array ( [cmtid] => 358 [ctime] => 1401327899094 [content] => 2013年8月1日18:36:29 o(∩_∩)o~ [replyid] => 0 [user] => array ( [userid] => 1 [nickname] => admin [usericon] => [userurl] => [usermetadata] => array ( [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] => array ( [0] => array ( [type] => 1 [desc] => [url] => http://img.sohu.itc/xxxx ) ) ) ))

你那是新版的吧!估计 数值型 超出最大了
你那是新版的吧!估计 数值型 超出最大了
新版的?怎么讲?
我把上面说测试正常的代码复制到我那里,就是提示数据错误。
看来真是环境问题啊
我把上面说测试正常的代码复制到我那里,就是提示数据错误。
看来真是环境问题啊
echo '';$pingluninfo = < http://localhost/?p=9 [ttime] => 1401327899094 [sourceid] => 9 [parentid] => 0 [categoryid] => [ownerid] => [metadata] => [comments] => array ( [0] => array ( [cmtid] => 358 [ctime] => 1401327899094 [content] => 2013年8月1日18:36:29 o(∩_∩)o~ [replyid] => 0 [user] => array ( [userid] => 1 [nickname] => admin [usericon] => [userurl] => [usermetadata] => array ( [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] => array ( [0] => array ( [type] => 1 [desc] => [url] => http://img.sohu.itc/xxxx ) ) ) ))

我把上面说测试正常的代码复制到我那里,就是提示数据错误。
看来真是环境问题啊
1401327899094 [sourceid] => 9 [parentid] => 0 [categoryid] => [ownerid] => [metadata] => [comments] => array ( [0] => array ( [cmtid] => 358 [ctime] => 1401327899094 [content] => 2013年8月1日18:36:29 o(∩_∩)o~ [replyid] => 0 [user] => array ( [userid] => 1 [nickname] => admin [usericon] => [userurl] => [usermetadata] => array ( [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] => array ( [0] => array ( [type] => 1 [desc] => [url] => http://img.sohu.itc/xxxx ) ) ) ))

测试无误
其它类似信息

推荐信息