Services_JSON::name_value()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.

array-walking function for use in generating JSON-formatted name-value pairs

Method of the class: Services_JSON{}

Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.

No Hooks.


String. JSON-formatted name-value pair, like '"name":value'


$Services_JSON = new Services_JSON();
$Services_JSON->name_value( $name, $value );
$name(string) (required)
name of key to use
$value(mixed) (required)
reference to an array element to be encoded


Deprecated since 5.3.0 Use the PHP native JSON extension instead.

Services_JSON::name_value() code WP 6.5.4

function name_value($name, $value)
    _deprecated_function( __METHOD__, '5.3.0', 'The PHP native JSON extension' );

    $encoded_value = $this->_encode($value);

    if(Services_JSON::isError($encoded_value)) {
        return $encoded_value;

    return $this->_encode((string) $name) . ':' . $encoded_value;