@@ -85,21 +85,37 @@ you need it or it can be used in a controller::
8585Adding Normalizers and Encoders
8686-------------------------------
8787
88- Once enabled, the ``serializer `` service will be available in the container
89- and will be loaded with four :ref: `encoders <component-serializer-encoders >`
90- (:class: `Symfony\\ Component\\ Serializer\\ Encoder\\ JsonEncoder `,
91- :class: `Symfony\\ Component\\ Serializer\\ Encoder\\ XmlEncoder `,
92- :class: `Symfony\\ Component\\ Serializer\\ Encoder\\ YamlEncoder `, and
93- :class: `Symfony\\ Component\\ Serializer\\ Encoder\\ CsvEncoder `) and the
94- :ref: `ObjectNormalizer normalizer <component-serializer-normalizers >`.
95-
96- You can load normalizers and/or encoders by tagging them as
88+ Once enabled, the ``serializer `` service will be available in the container.
89+ It comes with a set of useful :ref: `encoders <component-serializer-encoders >`
90+ and :ref: `normalizers <component-serializer-normalizers >`.
91+
92+ Encoders supporting the following formats are enabled:
93+
94+ * JSON: :class: `Symfony\\ Component\\ Serializer\\ Encoder\\ JsonEncoder `
95+ * XML: :class: `Symfony\\ Component\\ Serializer\\ Encoder\\ XmlEncoder `
96+
97+ As well as the following normalizers:
98+
99+ * :class: `Symfony\\ Component\\ Serializer\\ Normalizer\\ ObjectNormalizer ` to
100+ handle typical data objects
101+ * :class: `Symfony\\ Component\\ Serializer\\ Normalizer\\ DateTimeNormalizer ` for
102+ objects implementing the :class: `DateTimeInterface ` interface
103+ * :class: `Symfony\\ Component\\ Serializer\\ Normalizer\\ DataUriNormalizer ` to
104+ transform :class: `SplFileInfo ` objects in `Data URIs `_
105+ * :class: `Symfony\\ Component\\ Serializer\\ Normalizer\\ JsonSerializableNormalizer `
106+ to deal with objects implementing the :class: `JsonSerializable ` interface
107+ * :class: `Symfony\\ Component\\ Serializer\\ Normalizer\\ ArrayDenormalizer ` to
108+ denormalize arrays of objects using a format like `MyObject[] ` (note the `[] ` suffix)
109+
110+ Custom normalizers and/or encoders can also be loaded by tagging them as
97111:ref: `serializer.normalizer <reference-dic-tags-serializer-normalizer >` and
98112:ref: `serializer.encoder <reference-dic-tags-serializer-encoder >`. It's also
99113possible to set the priority of the tag in order to decide the matching order.
100114
101115Here is an example on how to load the
102- :class: `Symfony\\ Component\\ Serializer\\ Normalizer\\ GetSetMethodNormalizer `:
116+ :class: `Symfony\\ Component\\ Serializer\\ Normalizer\\ GetSetMethodNormalizer `, a
117+ faster alternative to the `ObjectNormalizer ` when data objects always use
118+ getters and setters:
103119
104120.. configuration-block ::
105121
@@ -310,3 +326,4 @@ take a look at how this bundle works.
310326.. _`ApiPlatform` : https://github.com/api-platform/core
311327.. _`JSON-LD` : http://json-ld.org
312328.. _`Hydra Core Vocabulary` : http://hydra-cg.com
329+ .. _`Data URIs` : https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
0 commit comments