Wednesday, November 4, 2015

How to use a constructor when deserializing in Jackson

To use a constructor when deserializing in Jackson,

do as follows:

@Data
public class ClickUrl {

  private final String url;
  private String finalUrl;

  @JsonCreator
  public AdcrClickUrl(@JsonProperty("url") String url) {
    this.url = url;
  }

}

Reference:
http://www.cowtowncoder.com/blog/archives/2011/07/entry_457.html

No comments:

Post a Comment