我有以下 JSON 格式的字符串:
{
"hooks":[
{
"type":"subscribe",
"id":1331741592.6925,
"email":"JoeX@test-email.com",
"status":"Active",
"custom_fields":"{\"first_name\":\"Joe\",\"last_name\":\"X\"}",
"ip_created":"24.199.200.142",
"list_id":"33",
"list_type":"internal",
"list_name":"Administrator List 2",
"list_optin":false
},
{
"type":"subscribe",
"id":1331741592.7067,
"email":"JaneY@test-email.com",
"status":"Active",
"custom_fields":"{\"first_name\": \"Jane\",\"last_name\":\"Y\"}",
"ip_created":"24.199.200.142",
"list_id":"33",
"list_type":"internal",
"list_name":"Administrator List 2",
"list_optin":false
}
]
}
我想使用 PHPjson_decode()
函数将其放入关联数组中。
当我运行脚本时,调试将新数组的值显示为null
,因此我认为解码失败。我们没有运行 PHP 5.3,所以我不能使用json_last_error()
. 这是代码:
$hooks = (the JSON string from above);
$hooksArray = json_decode($hooks, true);
任何想法为什么$hooksArray
会回来null
?