@param array $serializedObject

@return object
559363
private function deserializeObjectRecursively($serializedObject)
    {
        Assert::keyExists($serializedObject, 'class', "Key 'class' should be set.");
        Assert::keyExists($serializedObject, 'payload', "Key 'payload' should be set.");

        $reflection = new ReflectionClass($serializedObject['class']);
        $properties = $reflection->getProperties();
        $object = $reflection->newInstanceWithoutConstructor();

        foreach ($serializedObject['payload'] as $name => $value) {
            $matchedProperty = $this->findProperty($properties, $name);
            if (null === $matchedProperty) {
                throw new SerializationException(sprintf(
                    'Property \'%s\' not found for object \'%s\'',
                    $name,
                    $serializedObject['class']
                ));
            }

            $value = $this->deserializeValue($value);

            $matchedProperty->setAccessible(true);
            $matchedProperty->setValue($object, $value);
            $matchedProperty->setAccessible(false);
        }

        return $object;
    }
849785
public static function unserialize($serialized)
    {
        // Set Handle
        set_error_handler(function () {
        }, E_ALL);
        $result = unserialize((string) $serialized);
        // Restores the previous error handler function
        restore_error_handler();
        if ($result === false) {
            return false;
        }
        return $result;
    }
748971
public function deserialize($serializedObject, $type)
    {
        $deserializedObject = unserialize($serializedObject);

        if (!($deserializedObject instanceof $type)) {
            throw new \LogicException(
                sprintf(
                    'Unserialized object was expected to be of type "%s"',
                    $type
                )
            );
        }

        return $deserializedObject;
    }
1300340
public static function decode($input, $serialized = false)
    {
        // use Base64 encoding to workaround issues with invalid
        // or null characters in serialized string (#1489142)
        if ($serialized) {
            // Keep backward compatybility where base64 wasn't used
            if (strpos(substr($input, 0, 16), ':') !== false) {
                return self::decode(@unserialize($input));
            }

            return @unserialize(base64_decode($input));
        }

        if (is_object($input)) {
            foreach (get_object_vars($input) as $idx => $value) {
                $input->$idx = self::decode($value);
            }
            return $input;
        }
        else if (is_array($input)) {
            foreach ($input as $idx => $value) {
                $input[$idx] = self::decode($value);
            }
            return $input;
        }

        return utf8_decode($input);
    }
1261421
private static function getBlocksWithEnd(array $serializedBlocks): array
    {
        $blocksWithEnd = BlockSerializer::unserializeBlocksWithEnd($serializedBlocks);

        // check result contain only block indexes and the blocks are procedures
        assert(
            is_array($blocks = static::getBlocks($serializedBlocks)) &&
            static::debugCheckBlocksExist($blocksWithEnd, $blocks, BlockSerializer::TYPE__PROCEDURE)
        );

        return $blocksWithEnd;
    }
1209353
public function serialize(Serializable $object)
    {
        $reflectionClass = new \ReflectionClass($object);
        $data = [];
        foreach ($reflectionClass->getProperties() as $reflectionProperty) {
            if (!$reflectionProperty->isPublic()) {
                $reflectionProperty->setAccessible(true);
            }
            $data[$reflectionProperty->getName()] = $reflectionProperty->getValue($object);
        }

        return json_encode($data);
    }
676119
private static function decideEncode($object, &$serialized)
    {
        switch ($type = gettype($object)) {
            case 'integer':
                $serialized .= "i{$object}e";
                break;

            case 'string':
                self::encodeString($object, $serialized);
                break;

            case 'array':
                $function = self::getArraySerializer($object);
                self::$function($object, $serialized);
                break;

            case 'boolean':
                $serialized .= $object === true ? 'i1e' : 'i0e';
                break;

            default:
                throw new EncodingException("Invalid type for encoding: $type", $object);
        }
    }
863454
public function deserialize($serializedObject)
    {
        $serializedCommand = @json_decode($serializedObject, true);

        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new DeserializeException(json_last_error_msg());
        }

        $command = $this->serializer->deserialize($serializedCommand);

        if (!$command instanceof NamedCommand) {
            throw new DeserializeException('The deserialized object is not a command');
        }

        return $command;
    }
1045891
public function unserialize($serialized = null)
    {
        if (is_null($serialized)) {
            return unserialize($this->serialize);
        }

        return unserialize($serialized);
    }
25121
public function unserialize($serialized)
    {
        foreach (unserialize($serialized) as $property => $value) {
            $this->{$property} = $value;
        }
    }
660119
public function unserialize($serialized)
    {
        $list = unserialize($serialized);
        if (is_array($list)) {
            foreach ($list as $index => $value) {
                $this[$index] = $value;
            }
        }
    }
554565
protected function formatDataObject(DataObject $dataObject)
    {
        // api access control
        if (!RESTfulAPI::api_access_control($dataObject, 'GET')) {
            return null;
        }

        if (method_exists($dataObject, 'onBeforeSerialize')) {
            $dataObject->onBeforeSerialize();
        }
        $dataObject->extend('onBeforeSerialize');

        // setup
        $formattedDataObjectMap = array();

        // get DataObject config
        $class = get_class($dataObject);
        $db = Config::inst()->get($class, 'db');
        $has_one = Config::inst()->get($class, 'has_one');
        $has_many = Config::inst()->get($class, 'has_many');
        $many_many = Config::inst()->get($class, 'many_many');
        $belongs_many_many = Config::inst()->get($class, 'belongs_many_many');

        // Get a possibly defined list of "api_fields" for this DataObject. If defined, they will be the only fields
        // for this DataObject that will be returned, including related models.
        $apiFields = (array) Config::inst()->get($class, 'api_fields');

        //$many_many_extraFields = $dataObject->many_many_extraFields();
        $many_many_extraFields = $dataObject->stat('many_many_extraFields');

        // setup ID (not included in $db!!)
        $serializedColumnName = $this->serializeColumnName('ID');
        $formattedDataObjectMap[$serializedColumnName] = $dataObject->getField('ID');

        // iterate over simple DB fields
        if (!$db) {
            $db = array();
        }

        foreach ($db as $columnName => $fieldClassName) {
            // Check whether this field has been specified as allowed via api_fields
            if (!empty($apiFields) && !in_array($columnName, $apiFields)) {
                continue;
            }

            $serializedColumnName = $this->serializeColumnName($columnName);
            $formattedDataObjectMap[$serializedColumnName] = $dataObject->getField($columnName);
        }

        // iterate over has_one relations
        if (!$has_one) {
            $has_one = array();
        }
        foreach ($has_one as $columnName => $fieldClassName) {
            // Skip if api_fields is set for the parent, and this column is not in it
            if (!empty($apiFields) && !in_array($columnName, $apiFields)) {
                continue;
            }

            $serializedColumnName = $this->serializeColumnName($columnName);

            // convert foreign ID to integer
            $relationID = intVal($dataObject->{$columnName . 'ID'});
            // skip empty relations
            if ($relationID === 0) {
                continue;
            }

            // check if this should be embedded
            if ($this->isEmbeddable($dataObject->ClassName, $columnName)) {
                // get the relation's record ready to embed
                $embedData = $this->getEmbedData($dataObject, $columnName);
                // embed the data if any
                if ($embedData !== null) {
                    $formattedDataObjectMap[$serializedColumnName] = $embedData;
                }
            } else {
                // save foreign ID
                $formattedDataObjectMap[$serializedColumnName] = $relationID;
            }
        }

        // combine defined '_many' relations into 1 array
        $many_relations = array();
        if (is_array($has_many)) {
            $many_relations = array_merge($many_relations, $has_many);
        }
        if (is_array($many_many)) {
            $many_relations = array_merge($many_relations, $many_many);
        }
        if (is_array($belongs_many_many)) {
            $many_relations = array_merge($many_relations, $belongs_many_many);
        }

        // iterate '_many' relations
        foreach ($many_relations as $relationName => $relationClassname) {
            // Skip if api_fields is set for the parent, and this column is not in it
            if (!empty($apiFields) && !in_array($relationName, $apiFields)) {
                continue;
            }

            //get the DataList for this realtion's name
            $dataList = $dataObject->{$relationName}();

            //if there actually are objects in the relation
            if ($dataList->count()) {
                // check if this relation should be embedded
                if ($this->isEmbeddable($dataObject->ClassName, $relationName)) {
                    // get the relation's record(s) ready to embed
                    $embedData = $this->getEmbedData($dataObject, $relationName);
                    // embed the data if any
                    if ($embedData !== null) {
                        $serializedColumnName = $this->serializeColumnName($relationName);
                        $formattedDataObjectMap[$serializedColumnName] = $embedData;
                    }
                } else {
                    // set column value to ID list
                    $idList = $dataList->map('ID', 'ID')->keys();

                    $serializedColumnName = $this->serializeColumnName($relationName);
                    $formattedDataObjectMap[$serializedColumnName] = $idList;
                }
            }
        }

        if ($many_many_extraFields) {
            $extraFieldsData = array();

            // loop through extra fields config
            foreach ($many_many_extraFields as $relation => $fields) {
                $manyManyDataObjects = $dataObject->$relation();
                $relationData = array();

                // get the extra data for each object in the relation
                foreach ($manyManyDataObjects as $manyManyDataObject) {
                    $data = $manyManyDataObjects->getExtraData($relation, $manyManyDataObject->ID);

                    // format data
                    foreach ($data as $key => $value) {
                        // clear empty data
                        if (!$value) {
                            unset($data[$key]);
                            continue;
                        }

                        $newKey = $this->serializeColumnName($key);
                        if ($newKey != $key) {
                            unset($data[$key]);
                            $data[$newKey] = $value;
                        }
                    }

                    // store if there is any real data
                    if ($data) {
                        $relationData[$manyManyDataObject->ID] = $data;
                    }
                }

                // add individual DO extra data to the relation's extra data
                if ($relationData) {
                    $key = $this->serializeColumnName($relation);
                    $extraFieldsData[$key] = $relationData;
                }
            }

            // save the extrafields data
            if ($extraFieldsData) {
                $key = $this->serializeColumnName('ManyManyExtraFields');
                $formattedDataObjectMap[$key] = $extraFieldsData;
            }
        }

        if (method_exists($dataObject, 'onAfterSerialize')) {
            $dataObject->onAfterSerialize($formattedDataObjectMap);
        }
        $dataObject->extend('onAfterSerialize', $formattedDataObjectMap);

        return $formattedDataObjectMap;
    }
864188
public function unserialize($serialized)
    {
        $objectData = unserialize($serialized);

        foreach ($objectData as $propertyName => $propertyValue)
        {
            $this->{$propertyName} = $propertyValue;
        }
    }
396472
protected function sortObject($object)
    {
        $sort_array = get_object_vars($object);
        ksort($sort_array);

        $new_object = new stdClass();
        foreach ($sort_array as $key => $value) {
            if (is_object($value)) {
                $value = $this->sortObject($value);
            }
            $new_object->$key = $value;
        }

        unset($sort_array);
        unset($object);

        return $new_object;
    }
626592
public function serialize($object)
    {
        return $this->serializer->serialize(
            $object,
            'json',
            SerializationContext::create()->setSerializeNull(true)->setGroups(['preview'])
        );
    }
271480
public static function getSerializables($object)
    {
        $annotation = static::getAnnotation($object, Serializables::class);
        if(null !== $annotation)
        {
            return $annotation;
        }
        else
        {
            return null;
        }
    }
1201301
private function recursiveDeserialize($serializedObject)
    {
        if (!is_array($serializedObject)) {
            return $serializedObject;
        } elseif ($this->dataFormatter->isSerializedObject($serializedObject)) {
            return $this->deserializeObject($serializedObject);
        } else {
            $deserializedArray = [];
            foreach ($serializedObject as $key => $value) {
                $deserializedArray[$key] = $this->recursiveDeserialize($value);
            }

            return $deserializedArray;
        }
    }