PHP json_decode() returns NULL with valid JSON? PHP json_decode() returns NULL with valid JSON? json json

PHP json_decode() returns NULL with valid JSON?


This worked for me

json_decode( preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $json_string), true );


It could be the encoding of the special characters. You could ask json_last_error() to get definite information.

Update: The issue is solved, look at the "Solution" paragraph in the question.


You could try with it.

json_decode(stripslashes($_POST['data']))