Skip to content
JonathanO edited this page Jun 3, 2012 · 2 revisions

JsonProperty

Marks a getter/setter or a property for serialization/de-serialization. This must appear for every property you expect to be serialized/de-serialized.

Note that getters and setters must both be annotated if you expect marshalling to work in both directions.

Parameters

  1. name (string) The name of the property in the JSON. Defaults to a guess based on the property/method name.
  2. type (string) The type of the property. Defaults to "string". See AnnotationTypes

Examples

<?
class Baz {

/**
 * @JsonProperty(name="foo", type="integer")
 */
public $foo;

/**
 * Name will default to bar.
 * @JsonProperty(type="string")
 */
public function getBar() {
...
}

/**
 * Slightly contrived.
 * @JsonProperty(name="bar", type="string")
 */
public function setBaz($baz) {
...
}

Back to Annotations list

Clone this wiki locally