WP_REST_Server::get_json_last_error
Returns if an error occurred during most recent JSON encode/decode.
Strings to be translated will be in format like "Encoding error: Maximum stack depth exceeded".
Method of the class: WP_REST_Server{}
No Hooks.
Returns
false|String. Boolean false or string error message.
Usage
// protected - for code of main (parent) or child class $result = $this->get_json_last_error();
Changelog
| Since 4.4.0 | Introduced. |
WP_REST_Server::get_json_last_error() WP REST Server::get json last error code WP 6.9.1
protected function get_json_last_error() {
if ( JSON_ERROR_NONE === json_last_error() ) {
return false;
}
return json_last_error_msg();
}