Services_JSON::encode()publicWP 1.0

Deprecated from version 5.3.0. It is no longer supported and can be removed in future releases. Use PHP native JSON extension instead.

encodes an arbitrary variable into JSON format (and sends JSON Header)

Method of the class: Services_JSON{}

No Hooks.

Return

Mixed. JSON string representation of input var or an error if a problem occurs

Usage

$Services_JSON = new Services_JSON();
$Services_JSON->encode( $var );
$var(mixed) (required)
any number, boolean, string, array, or object to be encoded. see argument 1 to Services_JSON() above for array-parsing behavior. if var is a string, note that encode() always expects it to be in ASCII or UTF-8 format!

Changelog

Deprecated since 5.3.0 Use the PHP native JSON extension instead.

Services_JSON::encode() code WP 6.5.2

function encode($var)
{
    _deprecated_function( __METHOD__, '5.3.0', 'The PHP native JSON extension' );

    header('Content-Type: application/json');
    return $this->encodeUnsafe($var);
}