@@ -511,6 +511,32 @@ There are several types of normalizers available:
511
511
512
512
Objects are normalized to a map of property names to property values.
513
513
514
+ :class: `Symfony\\ Component\\ Serializer\\ Normalizer\\ JsonSerializableNormalizer `
515
+ This normalizer works with classes that implement :phpclass: `JsonSerializable `.
516
+
517
+ It will call the :phpmethod: `JsonSerializable::jsonSerialize ` method and
518
+ then further normalize the result. This means that nested
519
+ :phpclass: `JsonSerializable ` classes will also be normalized.
520
+
521
+ This normalizer is particularly helpful when you want to gradually migrate
522
+ from an existing codebase using simple :phpfunction: `json_encode ` to the Symfony
523
+ Serializer by allowing you to mix which normalizers are used for which classes.
524
+
525
+ Unlike with :phpfunction: `json_encode ` circular references can be handled.
526
+
527
+ :class: `Symfony\\ Component\\ Serializer\\ Normalizer\\ DateTimeNormalizer `
528
+ This normalizer converts :phpclass: `DateTimeInterface ` objects (e.g.
529
+ :phpclass: `DateTime ` and :phpclass: `DateTimeImmutable `) into strings.
530
+ By default it uses the RFC3339 _ format.
531
+
532
+ :class: `Symfony\\ Component\\ Serializer\\ Normalizer\\ DataUriNormalizer `
533
+ This normalizer converts :phpclass: `SplFileInfo ` objects into a data URI
534
+ string (``data:... ``) such that files can be embedded into serialized data.
535
+
536
+ .. versionadded :: 3.1
537
+ The ``JsonSerializableNormalizer ``, ``DateTimeNormalizer `` and
538
+ ``DataUriNormalizer `` normalizers were added in Symfony 3.1
539
+
514
540
Handling Circular References
515
541
----------------------------
516
542
@@ -653,3 +679,4 @@ you indicate that you're expecting an array instead of a single object.
653
679
654
680
.. _`JMS serializer` : https://github.com/schmittjoh/serializer
655
681
.. _Packagist : https://packagist.org/packages/symfony/serializer
682
+ .. _RFC3339 : https://tools.ietf.org/html/rfc3339#section-5.8
0 commit comments