How to decode a string?

How to decode such a string? json_decode() fails //NULL

$string=array('{["{"id":432067845,"first_name":"mark","last_name":"Sergeev","is_closed":false,"can_access_closed":true,"sex":2,"bdate":"29_6_1983","city":{"id":1,"title":"Moskva"},"country":{"id":1,"title":"Russia"},"photo_100":"https://sun1-84_userapi_com/c855628/v855628666/152ba6/LhxTHnMO9Ys_jpg?ava"]=>
 string(104) "1","photo_200":"https://sun1-93.userapi.com/c855628/v855628666/152ba5/-kjl1kGs9Fo.jpg?ava=1","online":1}"');

var_dump(json_decode($string[0])) //Get NULL


How to decode?
April 3rd 20 at 18:47
2 answers
April 3rd 20 at 18:49
View the response to a similar question on stackoverflow
Looked at me a curve object of some kind comes
kUxwUt4n5Lo.jpg
array(1) {
["{"id":432067845,"first_name":"mark","last_name":"Sergeev","is_closed":false,"can_access_closed":true,"sex":2,"bdate":"29_6_1983","city":{"id":1,"title":"Moskva"},"country":{"id":1,"title":"Russia"},"photo_100":"https://sun9-29_userapi_com/c855628/v855628666/152ba6/LhxTHnMO9Ys_jpg?ava"]=>
 string(104) "1","photo_200":"https://sun9-49.userapi.com/c855628/v855628666/152ba5/-kjl1kGs9Fo.jpg?ava=1","online":1}"
}

AJAX send so
const request = new XMLHttpRequest();
 const url="roomUser/BootData.php";
console.info(app.VK_info)
 const params = JSON.stringify(app.VK_info);
 //request.responseType = "json";
 request.open("POST", url, true);
 request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
 request.addEventListener("readystatechange", () => {
 if (request.readyState === 4 && request.status === 200) {
 window.app.boot = request.response;
console.info(app.boot)
}
});

 request.send(params);

In app.VK_info ordinary object

chlPTDpk3m0.jpg

I follow the example here - Catherine_Hickl commented on April 3rd 20 at 18:52
The object is not correct whyHnMO9Ys_jpg?ava"]=> at the end of the arrow json_decode() will not work - Catherine_Hickl commented on April 3rd 20 at 18:55
With jquery everything works fine and comes
$.ajax({
 url: "roomUser/BootData.php",
type:"POST",
 dataType: "JSON",
data:{bootdata:app.VK_info},
 success:function (BootData) {
window.app.BootData=BootData;
}
})
- Catherine_Hickl commented on April 3rd 20 at 18:58
@Catherine_Hickl, give the entire code as you serialized "ordinary object" before sending? - sandrine_Nienow41 commented on April 3rd 20 at 19:01
April 3rd 20 at 18:51
The case in Content-type: you at loggerheads with the code from the example with application/x-www-form-urlencoded, which involves sending data in GET parameters: a=1&b=2&c=3

While sending JSON-encoded data.

Replace
request.setRequestHeader("Content-Type", "application/json;charset=UTF-8");

Find more questions by tags PHP