File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -754,6 +754,25 @@ This encoder requires the :doc:`Yaml Component </components/yaml>` and
754
754
transforms from and to Yaml.
755
755
756
756
757
+ Skipping ``null `` Values
758
+ ------------------------
759
+
760
+ By default, the Serializer will preserve properties containing a ``null `` value.
761
+ You can change this behavior by setting the ``skip_null_values `` context option
762
+ to ``true ``::
763
+
764
+ $dummy = new class {
765
+ public $foo;
766
+ public $bar = 'notNull';
767
+ };
768
+
769
+ $normalizer = new ObjectNormalizer();
770
+ $result = $normalizer->normalize($dummy, 'json', ['skip_null_values' => true]);
771
+ // ['bar' => 'notNull']
772
+
773
+ .. versionadded :: 4.2
774
+ The ``skip_null_values `` option was introduced in Symfony 4.2.
775
+
757
776
.. _component-serializer-handling-circular-references :
758
777
759
778
Handling Circular References
You can’t perform that action at this time.
0 commit comments