假设我有一个像
{
[
{"id" : 1, "src" : src1, "name" : name1},
{"id" : 2, "src" : src2, "name" : name2},
{"id" : 3, "src" : src3, "name" : name3},
{"id" : 4, "src" : src4, "name" : name4}
]
}
我应该如何在 php 中解码这个 json 数组?
$project_info_json = $_POST['project_info_json'];
if (get_magic_quotes_gpc()) {
$project_info_json = stripslashes($_POST['project_info_json']);
}else {
$project_info_json = $_POST['project_info_json'];
}
$project_info_array = json_decode($project_info_json, true);
我已经尝试过 json_decode 方法,但似乎 $project_info_array 的元素计数为 0。谁能告诉我我做错了什么?