I am trying to get data from a post request using the following line :
$data = file_get_contents('php://input');
The json string might be like: {"test" : "test one \xe0 "}
The problem is when I try to do a json_decode($data), I get null. By var_dump()ing $data, I see some characters like \xe0 \xe7a.
The data sent is in utf-8. I use utf8_decode($data) as well, but with no luck. Could someone explain what I am missing or how to solve this issue?
I need to convert the invalid json from:
$data = '{"test" : "test one \xe0 "}';
to:
$data = '{"test" : "test one à "}';
\xis not allowed in JSON./xe0for example and then attempt to decode again. But doesn't make sense to send JSON if you are going to send invalid JSON.json_decode