From c63e048089a05c2d9cf42da33e7e1bdcd904e69f Mon Sep 17 00:00:00 2001 From: Alan Poulain Date: Tue, 5 Mar 2019 15:57:18 +0100 Subject: [PATCH] Document the use of ignored_attributes context option --- components/serializer.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/serializer.rst b/components/serializer.rst index a155341c2c9..c48852efa22 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -413,6 +413,11 @@ method on the normalizer definition:: $serializer = new Serializer([$normalizer], [$encoder]); $serializer->serialize($person, 'json'); // Output: {"name":"foo","sportsperson":false} +You can also use the ``ignored_attributes`` option of the context to ignore attributes when +normalizing an object:: + + $serializer->serialize($person, 'json', ['ignored_attributes' => ['age']]); + .. _component-serializer-converting-property-names-when-serializing-and-deserializing: Converting Property Names when Serializing and Deserializing