我有JSON字符串,如:json_decode php5.3錯誤或錯過了解?
'"[{\"type\": \"EDITOR\", \"value\": \"fsddfsdsfdfs\"}, {\"type\": \"CITA\", \"value\": \"Bug:\\n\\t\\t\\t\\t\\t0 open/0\\n\\t\\t\\t\\n \\n Feature:\\n\\t\\t\\t\\t\\t1 open/1\\n\\t\\t\\t\"}]"'
json_decode未能解碼。
刪除「從開始和結束標記使得它的工作
'[{\"type\": \"EDITOR\", \"value\": \"fsddfsdsfdfs\"}, {\"type\": \"CITA\", \"value\": \"Bug:\\n\\t\\t\\t\\t\\t0 open/0\\n\\t\\t\\t\\n \\n Feature:\\n\\t\\t\\t\\t\\t1 open/1\\n\\t\\t\\t\"}]'
測試代碼
$test1 = '"[{"type": "EDITOR", "value": "fsddfsdsfdfs"}, {"type": "CITA", "value": "Bug: 0 open/0 Feature: 1 open/1 "}]"';
print_r(json_decode($test1));
echo json_last_error().'<br>';
$test2 = '[{"type": "EDITOR", "value": "fsddfsdsfdfs"}, {"type": "CITA", "value": "Bug: 0 open/0 Feature: 1 open/1 "}]';
print_r(json_decode($test2));
我缺少的東西或用錯了?
您似乎已經有了解決方案:刪除開頭和結尾''' –
所有這些反斜槓都是字符串的一部分?!? – deceze