json_last_error
PHP 5 >= 5.3.0, PHP 7, PHP 8
json_last_error - Returns the last error occurred
Example #1 json_last_error example
Result: Decoding: {"Organization": "PHP Documentation Team"} - No errors
Decoding: {'Organization': 'PHP Documentation Team'} - Syntax error, malformed JSON
Example #2 json_last_error with json_encode
Result: string(4) "null"
bool(true)
Example #3 json_last_error and <span class='function-constant'>JSON_THROW_ON_ERROR</span>
Result: bool(true)