Skip to content

Finish #4308: Documentation for the new PropertyNormalizer #5028

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 14, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
ref #4272 Documentation for the new PropertyNormalizer introduced in s…
  • Loading branch information
mnapoli committed Nov 1, 2014
commit 421aa41611175fb43cf3fbd473dbce8287ee5c17
24 changes: 24 additions & 0 deletions components/serializer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,30 @@ When serializing, you can set a callback to format a specific object property::
$serializer->serialize($person, 'json');
// Output: {"name":"cordoval", "age": 34, "createdAt": "2014-03-22T09:43:12-0500"}

Normalizers
-----------

There are several types of normalizers available::

* The :class:`Symfony\\Component\\Serializer\\Normalizer\\GetSetMethodNormalizer`

This normalizer reads the content of the class by calling the "getters" (public
methods starting with "get"). It will denormalize data by calling the constructor
and the "setters" (public methods starting with "set").

Objects are serialized to a map of property names (method name stripped of the "get"
prefix and converted to lower case) to property values.

* The :class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer`

.. versionadded:: 2.6
The :class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer`
class was introduced in Symfony 2.6.

This normalizer directly reads and writes public properties as well as
**private and protected** properties. Objects are serialized to a map of
property names to property values.

Handling Circular References
----------------------------

Expand Down