method isJson documentation in bbn\Str
Checks if the string is a json string.
Example
X::dump(\bbn\Str::isJson('{"firstName": "John", "lastName": "Smith", "age": 25}'));
// (bool) true
function($st)
{
if (\is_string($st) && !empty($st)
&& ( (substr($st, 0, 1) === '{') || (substr($st, 0, 1) === '[') )
) {
json_decode($st);
return (json_last_error() == JSON_ERROR_NONE);
}
return false;
}
Checks if the string is a json string. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2025
BBN Solutions