try {
json_decode($_POST["var"]);
}
catch(Exception $e) {
exit($e->getMessage());
}


P.S. dovrei aver risposto ad entrambi i post in un colpo solo