Skip to content

Commit e77facb

Browse files
authored
Update JsonTransformer.php
1 parent 10a78e1 commit e77facb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/JsonTransformer.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ public function serialize($value)
5454
$this->noMappingGuard();
5555

5656
if (\is_array($value) && !empty($value[Serializer::MAP_TYPE])) {
57-
$data = ['total' => count($value)];
57+
$data = ['total' => 0];
5858
unset($value[Serializer::MAP_TYPE]);
59+
5960
foreach ($value[Serializer::SCALAR_VALUE] as $v) {
6061
$data[self::EMBEDDED_KEY][] = $this->serializeObject($v);
6162
}
63+
$data['total'] = count($data[self::EMBEDDED_KEY]);
6264
} else {
6365
$data = $this->serializeObject($value);
6466
}

0 commit comments

Comments
 (0)