JSON.stringify escaping without need


How can I construct a POST request body in React Native not with a stringified json but a json?

Finally, my colleague found a solution. Request body should be constructed in this way:

body: 'data=' + JSON.stringify(param)

JSON.stringify is converting my json object to the following string


When it should not be escaped. The result should be as the string quoted below


Rather than use a general replace of all the escaped quotes and remove ones that could be in the input. How can I set JSON.stringify to not double escape the variables?

Something is really messed up here. First, your initial JSON is not valid. Somehow it is already has extra slashes.

Check here: Issue with JSON.stringify adding a extra \ and "" to my Json object. Maybe here: JSON.stringify escaping without need

Also there is missing } in the very end of JSON string (it should be }}} three closing brackets).

Secondly, I guess before you inserted it in database you escaped it (so thats how you got even more slashes) and you did htmlspecialchars(). Considering this, thats how you can parse it in object.

$info = json_decode(stripslashes(htmlspecialchars_decode($tmp.'}')));