Skip to content
JonathanO edited this page Oct 14, 2012 · 3 revisions

JsonAnyGetter

A method annotated with this is expected to return an array of key-values to add to the result of serializing the object. It must take exactly 0 parameters.

There can only be one @JsonAnyGetter per class.

This is very commonly used with @JsonAnySetter

Parameters

There aren't any.

Example

class Foo {

    private $anyStuff = array();

    /**
     * @JsonAnySetter
     */
    function amSetter($key, $value) {
        $this->anyStuff[$key] = $value;
    }

    /**
     * @JsonAnyGetter
     */
    function getStuff() {
        return $this->anyStuff;
    }
}
Clone this wiki locally