diff --git a/src/Handler/Handlers/ObjectHandler.php b/src/Handler/Handlers/ObjectHandler.php index 1c2129e..840f967 100644 --- a/src/Handler/Handlers/ObjectHandler.php +++ b/src/Handler/Handlers/ObjectHandler.php @@ -54,7 +54,7 @@ public function serialize(mixed $value, Metadata $metadata, SerializationContext public static function supportsDeserialize(mixed $value, string $type): bool { - return is_array($value); + return is_array($value) || ($value instanceof \stdClass && $type === Type::BUILTIN_TYPE_ARRAY); } /** @@ -64,6 +64,9 @@ public static function supportsDeserialize(mixed $value, string $type): bool */ public function deserialize(mixed $value, Metadata $metadata): object|iterable { + if ($value instanceof \stdClass && Type::BUILTIN_TYPE_ARRAY === $metadata->type) { + return (array) $value; + } if (is_a($metadata->type, Collection::class, true)) { /** @var Collection $collection */ $collection = new ArrayCollection();