转换json arry时出错

时间:2017-01-22 11:36:19

标签: php json angular

从angularjs 2

我的应用程序获得低于json值但我无法将此json值转换为数组。

    $response = '{username: "mosh", time: "2017-01-22T11:28:54.422Z"}';
    $json_arrya = json_decode($response,true);
    var_dump($json_arrya);

当前输出:NULL 预期输出为数组

1 个答案:

答案 0 :(得分:0)

尝试下面的json

{
    "username": "mosh",
    "time": "2017-01-22T11:28:54.422Z"
}

看看是否有效。

此外,这是一个json对象而不是数组,因此您可能必须将其作为数组从角度服务传递,如

[{ "username": "mosh", "time": "2017-01-22T11:28:54.422Z"}]