src/Common/Internal/Serialization/JsonSerializer.php
public static function objectSerialize($targetObject, $rootName)
    {
        Validate::notNull($targetObject, 'targetObject');
        Validate::isString($rootName, 'rootName');

        $container = new \stdClass();

        $container->$rootName = $targetObject;

        return json_encode($container);
    }
public static function objectSerialize($targetObject, $rootName)
    {
        Validate::notNull($targetObject, 'targetObject');
        Validate::isString($rootName, 'rootName');

        $container = new \stdClass();

        $container->$rootName = $targetObject;

        return json_encode($container);
    }
public static function objectSerialize ( $ targetObject , $ rootName ) { Validate :: notNull ( $ targetObject , 'targetObject' ) ; Validate :: isString ( $ rootName , 'rootName' ) ; $ container = new \ stdClass ( ) ; $ container -> $ rootName = $ targetObject ; return json_encode ( $ container ) ; }
Serialize an object with specified root element name.

@param object $targetObject The target object
@param string $rootName     The name of the root element

@return string
Serialize an object with specified root element name .