/** * invoke this method when you want to validate json */ public static function checkJSON($json, $rules, $strict = false) { /** * create object of this class */ $checker = new self(); /** * main function * invoke it for json checking */ $result_array = $checker->check($json, $rules, array()); $checker->countJsonKeys($json); /** * if strict option is true then * check on strict matching */ if ($strict) { if ($checker->rules_keys_number != $checker->json_keys_number) { return false; } } /** * if we don't found the false in the result_array * then return true */ if (array_search(false, $result_array) === false) { return true; } else { return false; } }