JSON String inside a JSON JSON String inside a JSON json json

JSON String inside a JSON


There is no problem. It's just your console.log that shows all strings by simply delimiting with ".

As you say this request object is used in a JSON request, where it will be JSON.stringifyed another time, with the valid result

{"t":"{\"a\":1,\"b\":\"a sample text\"}","c":2,"r":"some text"}


That's just the way the browser console shows you the value of a string, by wrapping in double quotes for the output. This is perfectly normal and nothing is broken.

You can test it by transforming your JSON string back to an object and using a property.

console.log( JSON.parse(request.t).b ); // a sample text


Well, this may not be helpful. But, I ran into an issue where the JSON string inside a JSON had no property. I was able to parse the JSON string doing the following:

//Return from remote php request {'{"firsttest": 0, ""scndTest": 1"}'};// How to access let data = Object.Keys(jsonWJsonString)[0];let justJSONValue = JSON.parse(data);

this works because there is no object property to reference so an index value can be used; which gives us the JSONString. Hope that helped anyone. Cheers