Answers for "php json decode with validation"

PHP
-1

php try json decode and check

// Checks if json
function isJson($string) {
   json_decode($string);
   return json_last_error() === JSON_ERROR_NONE;
}

// example
if (isJson($string) {
  // Do your stuff here
}
Posted by: Guest on July-30-2021

Browse Popular Code Answers by Language