Convert the serialized array into an object

@param  array $value
@return object
@throws JsonSerializerException
482783
protected function unserializeObject($value)
    {
        $className = $value[static::CLASS_IDENTIFIER_KEY];
        unset($value[static::CLASS_IDENTIFIER_KEY]);

        if ($className[0] === '@') {
            $index = substr($className, 1);
            return $this->objectMapping[$index];
        }

        if (array_key_exists($className, $this->customObjectSerializerMap)) {
            $obj = $this->customObjectSerializerMap[$className]->unserialize($value);
            $this->objectMapping[$this->objectMappingIndex++] = $obj;
            return $obj;
        }

        if (!class_exists($className)) {
            throw new JsonSerializerException('Unable to find class ' . $className);
        }

        if ($className === 'DateTime') {
            $obj = $this->restoreUsingUnserialize($className, $value);
            $this->objectMapping[$this->objectMappingIndex++] = $obj;
            return $obj;
        }

        if (!$this->isSplList($className)) {
            $ref = new ReflectionClass($className);
            $obj = $ref->newInstanceWithoutConstructor();
        } else {
            $obj = new $className();
        }

        if ($obj instanceof \SplDoublyLinkedList) {
            $obj->unserialize($value['value']);
            $this->objectMapping[$this->objectMappingIndex++] = $obj;
            return $obj;
        }

        $this->objectMapping[$this->objectMappingIndex++] = $obj;
        foreach ($value as $property => $propertyValue) {
            try {
                $propRef = $ref->getProperty($property);
                $propRef->setAccessible(true);
                $propRef->setValue($obj, $this->unserializeData($propertyValue));
            } catch (ReflectionException $e) {
                switch ($this->undefinedAttributeMode) {
                    case static::UNDECLARED_PROPERTY_MODE_SET:
                        $obj->$property = $this->unserializeData($propertyValue);
                        break;
                    case static::UNDECLARED_PROPERTY_MODE_IGNORE:
                        break;
                    case static::UNDECLARED_PROPERTY_MODE_EXCEPTION:
                        throw new JsonSerializerException('Undefined attribute detected during unserialization');
                        break;
                }
            }
        }
        if (method_exists($obj, '__wakeup')) {
            $obj->__wakeup();
        }
        return $obj;
    }
71920
private function decodeJson($value)
    {
        $decodedValue = json_decode($value, true);
        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new \InvalidArgumentException('JSON parsing error: ' . json_last_error_msg());
        }

        return $decodedValue;
    }
650945
public static function serialize($value)
    {
        if (is_resource($value)) {
            throw SerializationFailedException::forValue($value);
        }

        try {
            $serialized = serialize($value);
        } catch (Exception $e) {
            throw SerializationFailedException::forValue($value, $e->getMessage(), $e->getCode(), $e);
        }

        return $serialized;
    }
913028
public function toArray($value)
    {
        if (!is_object($value)) {
            throw new TypeCastException('Is not object');
        }

        foreach ($this->rules as $class => $rule)
        {
            if (get_class($value) === $class) {
                return $this->createMap($class, $value);
            }
        }

        throw new TypeCastException('Rule not found');
    }
1013756
private function makeReal($value)
    {
        if (is_array($value)) {
            foreach ($value as $key => $val) {
                $value[$key] = $this->makeReal($val);
            }
        }

        if ($value instanceof ObjectStub) {
            return $value->getObject();
        }

        return $value;
    }
764099
protected function unserializeType($value, $type)
    {
        if ($type === self::TYPE_JSON) {
            // overwrite the doctrine json type since it uses the assoc
            // parameter. This is a problem for empty objects since we cant
            // distinguish between an empty array or object
            if ($value === null) {
                return null;
            } elseif ($value === '') {
                return new \stdClass();
            } elseif (is_resource($value)) {
                $value = stream_get_contents($value);
            }

            return json_decode($value);
        } else {
            return $this->connection->convertToPHPValue(
                $value,
                TypeMapper::getDoctrineTypeByType($type)
            );
        }
    }
465568
public function fromJson($value, $asObject = false)
    {
        if (is_array($value)) {
            return $value;
        }

        return json_decode($value, !$asObject);
    }
385325
protected function unserializeObject(array $value)
    {
        $className = $value[self::CLASS_IDENTIFIER_KEY];
        unset($value[self::CLASS_IDENTIFIER_KEY]);

        if (isset($value[self::MAP_TYPE])) {
            unset($value[self::MAP_TYPE]);
            unset($value[self::SCALAR_VALUE]);
        }

        if ($className[0] === '@') {
            return self::$objectMapping[substr($className, 1)];
        }

        if (!class_exists($className)) {
            throw new SerializerException('Unable to find class '.$className);
        }

        return (null === ($obj = $this->unserializeDateTimeFamilyObject($value, $className)))
            ? $this->unserializeUserDefinedObject($value, $className) : $obj;
    }
1029919
public static function fromArray(array $value)
    {
        $language = null;
        $culture = null;

        if (!empty($value['language'])) {
            $language = $value['language'];
        } elseif ($value[0]) {
            $language = $value[0];
        }

        if (!empty($value['culture'])) {
            $culture = $value['culture'];
        } elseif ($value[1]) {
            $culture = $value[1];
        }

        return new static($language, $culture);
    }
173687
protected function legacySerializeArray(array $value)
    {
        $data = ['total' => 0];
        unset($value[Serializer::MAP_TYPE]);
        foreach ($value[Serializer::SCALAR_VALUE] as $v) {
            $data[self::EMBEDDED_KEY][] = $this->serializeObject($v);
        }
        $data['total'] = count($data[self::EMBEDDED_KEY]);

        return $data;
    }
1369779
public function serialize($value)
    {
        $this->noMappingGuard();

        if (\is_array($value) && !empty($value[Serializer::MAP_TYPE])) {
            $data = $this->serializedArray($value);
        } else {
            $data = $this->serializeObject($value);
        }

        return \json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
    }
963167
public function encode($value)
    {
        $json = json_encode($value);

        if ($code = json_last_error()) $this->throwError($code);

        return $json;
    }
1255740
protected function createArray(array &$value)
    {
        $size = count($value);
        if ($size > 0 && array_keys($value) !== range(0, $size - 1)) {
            return $this->createObjectFromArray($value);
        }

        $instance = new Value\ArrayValue;
        $this->register($value, $instance);

        foreach ($value as $key => &$subValue) {
            $instance->set($key, $this->createValue($subValue));
        }

        return $instance;
    }
732661
public static function toArray($value)
    {
        if (is_array($value)) {
            return $value;
        }

        if ($value instanceof Collection) {
            return $value->all();
        }

        return [$value];
    }
379662
private function normalizeValue($value)
    {
        if (is_resource($value)) {
            throw new JsonSerializerException("Can't serialize PHP resources.");
        }

        if ($value instanceof \Closure) {
            throw new JsonSerializerException("Can't serialize closures.");
        }

        if (is_object($value)) {
            return $this->normalizeObject($value);
        }

        if (is_array($value)) {
            return array_map([$this, 'normalizeValue'], $value);
        }

        return $value;
    }
1162474
public static function maybeEncode($value)
    {
        if (is_array($value) || is_object($value)) {
            $value = json_encode($value);
        }

        return $value;
    }
1171794
public function unserialize($value)
    {
        if (\is_array($value) && isset($value[self::SCALAR_TYPE])) {
            return $this->unserializeData($value);
        }

        $this->reset();

        return $this->unserializeData($this->serializationStrategy->unserialize($value));
    }