public function sanitizeForSerialization($data)
    {
        if (is_scalar($data) || null === $data) {
            $sanitized = $data;
        } else if ($data instanceof \DateTime) {
            $sanitized = $data->format(\DateTime::ISO8601);
        } else if (is_array($data)) {
            foreach ($data as $property => $value) {
                $data[$property] = $this->sanitizeForSerialization($value);
            }
            $sanitized = $data;
        } else if (is_object($data)) {
            $values = array();
            foreach (array_keys($data::$swaggerTypes) as $property) {
                $getter = $data::$getters[$property];
                if ($data->$getter() !== null) {
                    $values[$data::$attributeMap[$property]] = $this->sanitizeForSerialization($data->$getter());
                }
            }
            ksort($values);
            $sanitized = $values;
        } else {
            $sanitized = (string)$data;
        }

        return $sanitized;
    }
public function sanitizeForSerialization($data)
    {
        if (is_scalar($data) || null === $data) {
            $sanitized = $data;
        } else if ($data instanceof \DateTime) {
            $sanitized = $data->format(\DateTime::ISO8601);
        } else if (is_array($data)) {
            foreach ($data as $property => $value) {
                $data[$property] = $this->sanitizeForSerialization($value);
            }
            $sanitized = $data;
        } else if (is_object($data)) {
            $values = array();
            foreach (array_keys($data::$swaggerTypes) as $property) {
                $getter = $data::$getters[$property];
                if ($data->$getter() !== null) {
                    $values[$data::$attributeMap[$property]] = $this->sanitizeForSerialization($data->$getter());
                }
            }
            ksort($values);
            $sanitized = $values;
        } else {
            $sanitized = (string)$data;
        }

        return $sanitized;
    }
public function sanitizeForSerialization ( $ data ) { if ( is_scalar ( $ data ) || null === $ data ) { $ sanitized = $ data ; } else if ( $ data instanceof \ DateTime ) { $ sanitized = $ data -> format ( \ DateTime :: ISO8601 ) ; } else if ( is_array ( $ data ) ) { foreach ( $ data as $ property => $ value ) { $ data [ $ property ] = $ this -> sanitizeForSerialization ( $ value ) ; } $ sanitized = $ data ; } else if ( is_object ( $ data ) ) { $ values = array ( ) ; foreach ( array_keys ( $ data :: $ swaggerTypes ) as $ property ) { $ getter = $ data :: $ getters [ $ property ] ; if ( $ data -> $ getter ( ) !== null ) { $ values [ $ data :: $ attributeMap [ $ property ] ] = $ this -> sanitizeForSerialization ( $ data -> $ getter ( ) ) ; } } ksort ( $ values ) ; $ sanitized = $ values ; } else { $ sanitized = ( string ) $ data ; } return $ sanitized ; }
Build a JSON POST object

@param mixed $data the data to serialize

@return string serialized form of $data
Build a JSON POST object