Skip to content

Instantly share code, notes, and snippets.

@liviutudor
Created September 16, 2017 00:29
Show Gist options
  • Save liviutudor/783f3c6d3e4e1532a3cfff09327ff5f7 to your computer and use it in GitHub Desktop.
Save liviutudor/783f3c6d3e4e1532a3cfff09327ff5f7 to your computer and use it in GitHub Desktop.
Usage of Jackson annotations when removing setters and zero-args constructor
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
public class JacksonBean {
private final int value;
private final String another;
@JsonCreator
public JacksonBean(@JsonProperty("value") int value, @JsonProperty("another") String another) {
this.value = value;
this.another = another;
}
public int getValue() {
return value;
}
public String getAnother() {
return another;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment