-
Notifications
You must be signed in to change notification settings - Fork 12
@JsonInclude
JonathanO edited this page Apr 2, 2013
·
2 revisions
Specifies what values should be included when serializing to JSON. Can be specified on a class, or property/method basis.
- value (integer) A value from the Include enum.
- Include
- ALWAYS: always include this property
- NON_DEFAULT: Not implemented.
- NON_EMPTY: include if not empty()
- NON_NULL: include if !is_null()
Don't include null properties in the serialized form of this object. Additionally the foo field should not be included if it's considered empty().
For Doctrine driven annotations:
<?
/**
* @JsonInclude(JsonInclude::INCLUDE_NON_NULL)
*/
class Baz {
/**
* @JsonProperty
* @JsonInclude(JsonInclude::INCLUDE_NON_EMPTY)
*/
public $foo;
For Weasel annotations:
<?
/**
* @JsonInclude(JsonInclude.Include.NON_NULL)
*/
class Baz {
/**
* @JsonProperty
* @JsonInclude(JsonInclude.Include.NON_EMPTY)
*/
public $foo;