@@ -170,7 +170,7 @@ Converting Property Names when Serializing and Deserializing
170
170
interface was introduced in Symfony 2.7.
171
171
172
172
Sometimes serialized attributes must be named differently than properties
173
- or getter and setter methods of PHP classes.
173
+ or getter / setter methods of PHP classes.
174
174
175
175
The Serializer Component provides a handy way to translate or map PHP field
176
176
names to serialized names: The Name Converter System.
@@ -187,7 +187,7 @@ Given you have the following object::
187
187
And in the serialized form, all attributes must be prefixed by ``org_ `` like
188
188
the following::
189
189
190
- {"org_name": "Les-Tilleuls.coop ", "org_address": "Euratechnologies, 2 rue Hegel, 59160 Lomme , France"}
190
+ {"org_name": "Acme SARL ", "org_address": "Euratechnologies, 59000 Lille , France"}
191
191
192
192
A custom Name Converter can handle such cases::
193
193
@@ -222,11 +222,11 @@ and :class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer`::
222
222
$serializer = new Serializer(array(new JsonEncoder()), array($normalizer));
223
223
224
224
$obj = new Company();
225
- $obj->name = 'Les-Tilleuls.coop ';
226
- $obj->address = 'Euratechnologies, 2 rue Hegel, 59160 Lomme , France';
225
+ $obj->name = 'Acme SARL ';
226
+ $obj->address = 'Euratechnologies, 59000 Lille , France';
227
227
228
228
$json = $serializer->serialize($obj);
229
- // {"org_name": "Les-Tilleuls.coop ", "org_address": "Euratechnologies, 2 rue Hegel, 59160 Lomme , France"}
229
+ // {"org_name": "Acme SARL ", "org_address": "Euratechnologies, 59000 Lille , France"}
230
230
$objCopy = $serializer->deserialize($json);
231
231
// Same data as $obj
232
232
@@ -239,11 +239,11 @@ CamelCase to snake_case
239
239
The :class: `Symfony\\ Component\\ Serializer\\ NameConverter\\ CamelCaseToUnderscoreNameConverter `
240
240
interface was introduced in Symfony 2.7.
241
241
242
- In many formats, it's common to use underscores to separate words (also know
242
+ In many formats, it's common to use underscores to separate words (also known
243
243
as snake_case). However, PSR-1 specifies that the preferred style for PHP
244
244
properties and methods is CamelCase.
245
245
246
- Symfony provides a built-in Name Converter designed to translate between
246
+ Symfony provides a built-in name converter designed to transform between
247
247
snake_case and CamelCased styles during serialization and deserialization
248
248
processes::
249
249
0 commit comments