The response is 6.9 MB, containing 9767 student records, which is probably why the response is timing out for most people, the server is probably having a hard time generating the response. If you do manage to get the response and try to decode it, json_decode will return null because it is unable to decode the JSON. If you use the JSON_THROW_ON_ERROR flag, or check the json_last_error, you will learn that there is a syntax error in the JSON.
The problem is that there are two records that contain double backslashes. The backslash is a special character in JSON, and a literal backslash must be escaped using... another backslash. So in these two elements, the \\ needs to be \\\\
{
"StudentID": "10095",
"RegistrationNo": "10078",
"AdmissionDate": "01 Nov 2017",
"StudentName": "Aaniya Tariq",
"FatherName": "Tariq Shehzad",
"Gender": "Female",
"HomeAddress": "\\House No. 231-Block-H2, Johar Town",
"HomePhone": "0324-4514622",
"EmergencyPhone": "03064142718",
"DateOfBirth": "24 Sep 2012",
"ContactNo": "0324-4514622 ; 03064142718",
"FamilyNo": "03064142718",
"WebPassword": null,
"CampusName": "Al-Muqeet Campus",
"SessionYear": "2020-2021",
"ClassTitle": "Level-III",
"SectionTitle": "Green",
"CampusID": "31",
"SessionID": "12",
"ClassID": "6",
"SectionID": "1"
},
{
"StudentID": "15929",
"RegistrationNo": "15912",
"AdmissionDate": "12 Oct 2020",
"StudentName": "Fatima Tu Zahra \\ waseem Hashmi",
"FatherName": "M. Waseem Hassan Hashmi",
"Gender": "Female",
"HomeAddress": "Punjab small Industries, Rawwal Road, Multan",
"HomePhone": "N/A",
"EmergencyPhone": "033152701010",
"DateOfBirth": "16 Jan 2008",
"ContactNo": "N/A ; 033152701010",
"FamilyNo": "033152701010",
"WebPassword": null,
"CampusName": "Al-Awwal Campus",
"SessionYear": "2020-2021",
"ClassTitle": "Level-VIII",
"SectionTitle": "Green",
"CampusID": "9",
"SessionID": "12",
"ClassID": "11",
"SectionID": "1"
}
Fixing those two syntax errors allowed me to decode the JSON string.
$file = file_get_contents("http://bisscloud.britain.edu.pk:8841/BISSJSon/JSonStudentsAll.aspx");
try
{
$data = json_decode($file, true, 512, JSON_THROW_ON_ERROR);
echo sizeof($data['Students']) . PHP_EOL;
var_dump($data);
}
catch (JsonException $e)
{
echo 'Error code: '.$e->getCode().PHP_EOL;
echo $e->getMessage().PHP_EOL;
}
Warning: file_get_contents(http://bisscloud.britain.edu.pk:8841/BISSJSon/JSonStudentsAll.aspx): failed to open stream: Operation timed out in php shell code on line 1... try usingE_ERROR | E_WARNING | E_PARSEinerror_reportingand you should see it