Added control when decoding JSON and return the appropriate error

more infos: http://php.net/manual/fr/function.json-last-error.php