我有一个包含多个对象的 JSON 数组,并试图用来json_decode
制作一个关联数组。
样本数据
$json='[{
type: "cool",
category: "power",
name: "Robert Downey Jr.",
character: "Tony Stark / Iron Man",
bio: "cool kid"
},
{
type: "cool",
category: "power",
name: "Chris Hemsworth",
character: "Thor",
bio: "cool kid"
},
{
type: "NotCool",
category: "nothing",
name: "Alexis Denisof",
character: "The Other",
bio: "cool kid"
}]';
这就是我正在做的事情:
$data = json_decode($json, true);
这给了我一个NULL
结果。我究竟做错了什么?
(我是 PHP 新手。)