Skip to content

Commit 3ce1eac

Browse files
committed
Fixed missing JsonSerializable check
1 parent a897333 commit 3ce1eac

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Serializer/Adapter/ArraySerializerAdapter.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace MattJanssen\ApiResponseBundle\Serializer\Adapter;
44

5+
use JsonSerializable;
56
use MattJanssen\ApiResponseBundle\Serializer\ArraySerializable;
67

78
/**
@@ -55,6 +56,10 @@ private function serializedMixed($data, array $groups = null)
5556
return $this->serializedMixed($data->arraySerialize($groups), $groups);
5657
}
5758

59+
if ($data instanceof JsonSerializable) {
60+
return $this->serializedMixed($data->jsonSerialize(), $groups);
61+
}
62+
5863
// A non-serializable object returns as an empty \stdClass object.
5964
// This gets converted to {} by json_encode, where as an empty array is converted to [].
6065
return new \stdClass();

0 commit comments

Comments
 (0)