<?php

function isValidJSON($str) {
   json_decode($str);
   return json_last_error() == JSON_ERROR_NONE;
}

var_dump(isValidJSON(null));
var_dump(isValidJSON(""));