将响应字符串转换为php中的数组


Convert reponse string to array in php

我通过auth API获得字符串:

({
    "token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ...",
    "user":
     {
        "uid":"lda...",
        "sn":"Hugo",
        "mail":"abc@bla.com",
        "mobile":""
    }
})

我试过json_decode($ldapResponse)->user->uid,但

尝试获取非对象的属性时出错

出现。如何将此字符串转换为Array并在php中获得uid的值?

使用json_decode

$array= json_decode($your_json, TRUE);`