json_decode出错

时间:2011-08-01 13:53:54

标签: php json

我有以下json,我通过AJAX发送,但在服务器端json_decode返回一个空数组。我也发送不同的值,在这种情况下,它工作正常。我检查了这个link,这是一个有效的JSON。

[
    {
        "name": "bettype",
        "value": "All"
    },
    {
        "name": "bookies",
        "value": "Interwetten"
    },
    {
        "name": "sporttype",
        "value": "Soccer"
    },
    {
        "name": "team1",
        "value": "Braunschweig"
    },
    {
        "name": "team2",
        "value": "Bayern Munich"
    },
    {
        "name": "league",
        "value": "Germany DFB Cup (90`)"
    }
]

更新:

这是服务器端代码:

var_dump((stripslashes($_GET['data']));
var_dump(json_decode(stripslashes($_GET['data'])));

这是输出:

string(244) "[{"name":"bettype","value":"All"},{"name":"bookies","value":"Interwetten"},{"name":"sporttype","value":"Soccer"},{"name":"team1","value":"Braunschweig"},{"name":"team2","value":"Bayern Munich"},{"name":"league","value":"Germany DFB Cup (90�)"}]" NULL 

1 个答案:

答案 0 :(得分:1)

对我来说很好。

http://sandbox.phpcode.eu/g/80941.php

检查浏览器配置/字符集,然后重试