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.
Return
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.3
protected function get_json_last_error() { $last_error_code = json_last_error(); if ( JSON_ERROR_NONE === $last_error_code || empty( $last_error_code ) ) { return false; } return json_last_error_msg(); }