Feature: @JsonAnyGetter

(see Jira entry JACKSON-292 for details)

One improvement in Jackson 1.6 is the addition of @JsonAnyGetter which makes it easier to serialize "extra properties" that are bound using existing @JsonAnySetter annotated method.

For example, you could have bean like:

  public class ExtensibleBean
    public String name; // we always have name

    private void HashMap<String, String> properties;

    public ExtensibleBean() { }

    @JsonAnySetter public void add(String key, String value) {
      properties.put(key, value);

    @JsonAnyGetter public Map<String,String> getProperties() {
      return properties;

and would serialize to/from JSON like:

    "name" : "Foobar",
    "age" : 37,
    "occupation" : "coder man"


JacksonFeatureAnyGetter (last edited 2010-08-05 06:55:55 by TatuSaloranta)

Copyright ©2009 FasterXML, LLC