php解析页面json数据

正常的是直接使用json_decode()即可。

$json ='[{"a":1,"b":2,"c":3,"d":4,"e":5},{"a":1,"b":2,"c":3,"d":4,"e":5}]';  
$wwww=json_decode($json);
Array
(
    [0] => stdClass Object
        (
            [a] => 1
            [b] => 2
            [c] => 3
            [d] => 4
            [e] => 5
        )

    [1] => stdClass Object
        (
            [a] => 1
            [b] => 2
            [c] => 3
            [d] => 4
            [e] => 5
        )

)

但是,我的问题是json_decode之后为空。

解决办法:$temp=stripslashes(html_entity_decode($temp));

html_entity_decode() 函数的作用是把 HTML 实体转换为字符。
stripslashes() 函数的作用是删除反斜杠。

因为我的json数组中有地址,带有/,所有要处理一下。

posted @ 2017-05-23 14:12  一碗薄酒  阅读(264)  评论(0编辑  收藏  举报