123456789101112131415161718192021222324252627282930 |
- Defining which properties should be serialized
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- The default exclusion policy is to exclude nothing, that is all properties of the
- object will be serialized. If you only want to expose a few of the properties,
- then it is easier to change the exclusion policy, and only mark these few properties:
- .. code-block :: php
- <?php
- use JMS\SerializerBundle\Annotation\ExclusionPolicy;
- use JMS\SerializerBundle\Annotation\Expose;
- /**
- * The following annotations tells the serializer to skip all properties which
- * have not marked with @Expose.
- *
- * @ExclusionPolicy("all")
- */
- class MyObject
- {
- private $foo;
- private $bar;
- /**
- * @Expose
- */
- private $name;
- }
|