File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,26 @@ needs three parameters:
151
151
#. The name of the class this information will be decoded to
152
152
#. The encoder used to convert that i
8000
nformation into an array
153
153
154
+ By default, additional attributes that are not mapped to the denormalized object will be ignored
155
+ by the Serializer component. Set the ``allow_extra_attributes `` key of the deserialization context to ``false ``
156
+ to let the serializer throw an exception when additional attributes are passed.
157
+
158
+ This will throw an :class: `Symfony\\ Component\\ Serializer\\ Exception\\ ExtraAttributesException ` exception,
159
+ because city is not an attribute of the ``Person `` class::
160
+
161
+ $data = <<<EOF
162
+ <person>
163
+ <name>foo</name>
164
+ <age>99</age>
165
+ <city>Paris</city>
166
+ </person>
167
+ EOF;
168
+
169
+ $person = $serializer->deserialize($data, 'Acme\Person', 'xml', array(
170
+ 'allow_extra_attributes' => false,
171
+ ));
172
+
173
+
154
174
Deserializing in an Existing Object
155
175
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
156
176
You can’t perform that action at this time.
0 commit comments