Exclusion Strategies ==================== Introduction ------------ The serializer supports different exclusion strategies. Each strategy allows you to define which properties of your objects should be serialized. General Exclusion Strategies ---------------------------- If you would like to always expose, or exclude certain properties. Then, you can do this with the annotations ``@ExclusionPolicy``, ``@Exclude``, and ``@Expose``. 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 setVersion('1.0'); $serializer->serialize(new VersionObject(), 'json'); Creating Different Views of Your Objects ---------------------------------------- Another default exclusion strategy is to create different views of your objects. Let's say you would like to serialize your object in a different view depending whether it is displayed in a list view or in a details view. You can achieve that by using the ``@Groups`` annotation on your properties. .. code-block :: php setGroups(array('list')); $serializer->serialize(new BlogPost(), 'json');