PHP json_decode returns null value with Syntax error

I built PHP import script about,but my json_decode has started returning a NULL value and syntax error

Tired everything – Just can’t figure out why this has suddenly stopped working?

and also my json was valid json from online json editor

json_decode returns null [SOLUTION]:
$response = '{ "accounting" : [
 { "firstName" : "John", "lastName" : "Doe", "age" : 23 },
 { "firstName" : "Mary", "lastName" : "Smith", "age" : 32 }
],
"sales" : [ 
{ "firstName" : "Sally", "pf" : "5%", "age" : 27 }, 
{ "firstName" : "Jim", "pf" : "5%", "age" : 41 } 
]
}';

$response = str_replace("%", "", $response);
$response = str_replace("H\u0026A", "", $response);
$response = str_replace("\u0026", "", $response);
$response = stripslashes($response);
$result = json_decode($response);
print_r($result);

Leave a Reply

Your email address will not be published. Required fields are marked *