How to decode a string?

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

 string(104) "1","photo_200":"","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
array(1) {
 string(104) "1","photo_200":"","online":1}"

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


In app.VK_info ordinary object


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
 url: "roomUser/BootData.php",
 dataType: "JSON",
 success:function (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.

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

Find more questions by tags PHP