@@ -44,21 +44,37 @@ you need it or it can be used in a controller::
44
44
Adding Normalizers and Encoders
45
45
-------------------------------
46
46
47
- Once enabled, the serializer service will be available in the container
48
- and will be loaded with four :ref: `encoders <component-serializer-encoders >`
49
- (:class: `Symfony\\ Component\\ Serializer\\ Encoder\\ JsonEncoder `,
50
- :class: `Symfony\\ Component\\ Serializer\\ Encoder\\ XmlEncoder `,
51
- :class: `Symfony\\ Component\\ Serializer\\ Encoder\\ YamlEncoder `, and
52
- :class: `Symfony\\ Component\\ Serializer\\ Encoder\\ CsvEncoder `) and the
53
- :ref: `ObjectNormalizer normalizer <component-serializer-normalizers >`.
54
-
55
- You can load normalizers and/or encoders by tagging them as
47
+ Once enabled, the ``serializer `` service will be available in the container.
48
+ It comes with a set of useful :ref: `encoders <component-serializer-encoders >`
49
+ and :ref: `normalizers <component-serializer-normalizers >`.
50
+
51
+ Encoders supporting the following formats are enabled:
52
+
53
+ * JSON: :class: `Symfony\\ Component\\ Serializer\\ Encoder\\ JsonEncoder `
54
+ * XML: :class: `Symfony\\ Component\\ Serializer\\ Encoder\\ XmlEncoder `
55
+
56
+ As well as the following normalizers:
57
+
58
+ * :class: `Symfony\\ Component\\ Serializer\\ Normalizer\\ ObjectNormalizer ` to
59
+ handle typical data objects
60
+ * :class: `Symfony\\ Component\\ Serializer\\ Normalizer\\ DateTimeNormalizer ` for
61
+ objects implementing the :class: `DateTimeInterface ` interface
62
+ * :class: `Symfony\\ Component\\ Serializer\\ Normalizer\\ DataUriNormalizer ` to
63
+ transform :class: `SplFileInfo ` objects in `Data URIs `_
64
+ * :class: `Symfony\\ Component\\ Serializer\\ Normalizer\\ JsonSerializableNormalizer `
65
+ to deal with objects implementing the :class: `JsonSerializable ` interface
66
+ * :class: `Symfony\\ Component\\ Serializer\\ Normalizer\\ ArrayDenormalizer ` to
67
+ denormalize arrays of objects using a format like `MyObject[] ` (note the `[] ` suffix)
68
+
69
+ Custom normalizers and/or encoders can also be loaded by tagging them as
56
70
:ref: `serializer.normalizer <reference-dic-tags-serializer-normalizer >` and
57
71
:ref: `serializer.encoder <reference-dic-tags-serializer-encoder >`. It's also
58
72
possible to set the priority of the tag in order to decide the matching order.
59
73
60
74
Here is an example on how to load the
61
- :class: `Symfony\\ Component\\ Serializer\\ Normalizer\\ GetSetMethodNormalizer `:
75
+ :class: `Symfony\\ Component\\ Serializer\\ Normalizer\\ GetSetMethodNormalizer `, a
76
+ faster alternative to the `ObjectNormalizer ` when data objects always use
77
+ getters and setters:
62
78
63
79
.. configuration-block ::
64
80
@@ -193,3 +209,4 @@ take a look at how this bundle works.
193
209
.. _`ApiPlatform` : https://github.com/api-platform/core
194
210
.. _`JSON-LD` : http://json-ld.org
195
211
.. _`Hydra Core Vocabulary` : http://hydra-cg.com
212
+ .. _`Data URIs` : https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
0 commit comments