WP_HTTP_Response::jsonSerialize() WordPress Method

The WP_HTTP_Response::jsonSerialize() Wordpress method allows a user to serialize a WordPress HTTP response into JSON format. This is useful for creating an API or for debugging purposes.

WP_HTTP_Response::jsonSerialize() #

Retrieves the response data for JSON serialization.


Description

It is expected that in most implementations, this will return the same as get_data(), however this may be different if you want to do custom JSON data handling.


Top ↑

Return

(mixed) Any JSON-serializable value.


Top ↑

Source

File: wp-includes/class-wp-http-response.php

	public function jsonSerialize() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
		return $this->get_data();
	}


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.