WP_REST_Server::get_json_last_error() WordPress Method

The WP_REST_Server::get_json_last_error() function returns the last error that occurred during JSON decoding.

WP_REST_Server::get_json_last_error() #

Returns if an error occurred during most recent JSON encode/decode.


Description

Strings to be translated will be in format like "Encoding error: Maximum stack depth exceeded".


Top ↑

Return

(false|string) Boolean false or string error message.


Top ↑

Source

File: wp-includes/rest-api/class-wp-rest-server.php

	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();
	}


Top ↑

Changelog

Changelog
VersionDescription
4.4.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.