@@ -413,12 +413,10 @@ As for groups, attributes can be selected during both the serialization and dese
413
413
Ignoring Attributes
414
414
-------------------
415
415
416
- All attributes are included by default when serializing objects. You have two alternatives to ignore some of those attributes.
416
+ All attributes are included by default when serializing objects. There are two
417
+ options to ignore some of those attributes.
417
418
418
- * `Option 1: Using @Ignore annotation `_
419
- * `Option 2: Using the context `_
420
-
421
- Option 1: Using ``@Ignore `` annotation
419
+ Option 1: Using ``@Ignore `` Annotation
422
420
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
423
421
424
422
.. configuration-block ::
@@ -461,7 +459,7 @@ Option 1: Using ``@Ignore`` annotation
461
459
</class >
462
460
</serializer >
463
461
464
- You are now able to ignore specific attributes during serialization::
462
+ You can now ignore specific attributes during serialization::
465
463
466
464
use App\Model\MyClass;
467
465
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
@@ -477,12 +475,12 @@ You are now able to ignore specific attributes during serialization::
477
475
$data = $serializer->normalize($obj);
478
476
// $data = ['foo' => 'foo'];
479
477
480
-
481
- Option 2: Using the context
478
+ Option 2: Using the Context
482
479
~~~~~~~~~~~~~~~~~~~~~~~~~~~
483
480
484
- By providing an array via the ``AbstractNormalizer::IGNORED_ATTRIBUTES ``
485
- key in the ``context `` parameter of the desired serializer method::
481
+ Pass an array with the names of the attributes to ignore using the
482
+ ``AbstractNormalizer::IGNORED_ATTRIBUTES `` key in the ``context `` of the
483
+ serializer method::
486
484
487
485
use Acme\Person;
488
486
use Symfony\Component\Serializer\Encoder\JsonEncoder;
@@ -805,7 +803,7 @@ There are several types of normalizers available:
805
803
806
804
:class: `Symfony\\ Component\\ Serializer\\ Normalizer\\ ProblemNormalizer `
807
805
Normalizes errors according to the API Problem spec `RFC 7807 `_.
808
-
806
+
809
807
.. _component-serializer-encoders :
810
808
811
809
Encoders
0 commit comments