Skip to content

Latest commit

 

History

History
37 lines (28 loc) · 1.53 KB

normalizers.rst

File metadata and controls

37 lines (28 loc) · 1.53 KB
.. index::
   single: Serializer, Normalizers

Normalizers

Normalizers turn objects into arrays and vice versa. They implement :class:`Symfony\\Component\\Serializer\\Normalizers\\NormalizerInterface` for normalizing (object to array) and :class:`Symfony\\Component\\Serializer\\Normalizers\\DenormalizerInterface` for denormalizing (array to object).

Normalizers are enabled in the serializer passing them as its first argument:

use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer;

$normalizers = [new ObjectNormalizer()];
$serializer = new Serializer($normalizers);

Built-in Normalizers

Symfony includes the following normalizers but you can also :doc:`create your own normalizer </serializer/custom_normalizer>`: