@@ -1344,6 +1344,29 @@ normalizers (in order of priority):
1344
1344
This denormalizer converts an array of arrays to an array of objects
1345
1345
(with the given type). See :ref: `Handling Arrays <serializer-handling-arrays >`.
1346
1346
1347
+ ByUsing the PropertyInfoExtractor you can simply annotate the arrays by '@var Person[]'
1348
+
1349
+ .. configuration-block ::
1350
+ .. code-block :: php-standalone
1351
+ use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
1352
+ use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
1353
+ use Symfony\Component\PropertyInfo\PropertyInfoExtractor;
1354
+ use Symfony\Component\Serializer\Encoder\JsonEncoder;
1355
+ use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
1356
+ use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader;
1357
+ use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
1358
+ use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
1359
+ use Symfony\Component\Serializer\Serializer;
1360
+
1361
+ $reflectionExtractor = new ReflectionExtractor();
1362
+ $phpDocExtractor = new PhpDocExtractor();
1363
+ $propertyInfo = new PropertyInfoExtractor([], [$phpDocExtractor, $reflectionExtractor]);
1364
+
1365
+ $classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
1366
+ $normalizers = [new ObjectNormalizer($classMetadataFactory, null, null, $propertyInfo), new ArrayDenormalizer()];
1367
+
1368
+ $this->serializer = new Serializer($normalizers, [new JsonEncoder()]);
1369
+
1347
1370
:class: `Symfony\\ Component\\ Serializer\\ Normalizer\\ ObjectNormalizer `
1348
1371
This is the most powerful default normalizer and used for any object
1349
1372
that could not be normalized by the other normalizers.
0 commit comments