-
Notifications
You must be signed in to change notification settings - Fork 12
@JsonAnySetter
JonathanO edited this page Oct 14, 2012
·
3 revisions
Method annotation to handle unknown properties when deserializing. The AnySetter method is expected to store the unknowns when deserializing. Having an AnySetter will prevent warnings being lobbed for unknown properties, instead they'll be passed to your AnySetter.
A method annotated with @JsonAnySetter must take exactly two parameters, the key and the value to store.
There can only be one @JsonAnySetter per class.
This is commonly used with @JsonAnyGetter
There aren't any.
class Foo {
private $anyStuff = array();
/**
* @JsonAnySetter
*/
function amSetter($key, $value) {
$this->anyStuff[$key] = $value;
}
/**
* @JsonAnyGetter
*/
function getStuff() {
return $this->anyStuff;
}
}