Burak.H :
I pull data from a json file on the remote server. This json file has 97000 Lines of json code. It returns null when I decode the Json file. When I debug the Json errors, I see that there is no error.
Json file : https://opendata.ecdc.europa.eu/covid19/casedistribution/json/
$json = file_get_contents("https://opendata.ecdc.europa.eu/covid19/casedistribution/json/");
$json = json_decode($json, true);
var_dump($json); // Return Null
But when I decode another json file there is no error
$json = file_get_contents("https://randomuser.me/api/");
$json = json_decode($json, true);
var_dump($json); // Return Array
Could this be due to the size of the data?
Thanks for advance
deceze :
The file starts with a BOM, which is a syntax error for json_decode
.
Ultimately this should be fixed by the host, as a workaround you can strip the first three bytes:
if (substr($json, 0, 3) == "\xEF\xBB\xBF") {
$json = substr($json, 3);
}
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=383043&siteId=1