I am unable to handle JSON decode errors. Here is my code:
try {
$jsonData = file_get_contents($filePath) . \']\';
May be you can try, validating json_decode
try {
$jsonData = file_get_contents($filePath) . ']';
$jsonObj = json_decode($jsonData, true);
if (is_null($jsonObj)) {
throw ('Error');
}
} catch (Exception $e) {
echo '{"result":"FALSE","message":"Caught exception: ' .
$e->getMessage() . ' ~' . $filePath . '"}';
}
Read this too