It's not necessary to change the name of the setter method to avoid ambiguity. You're otherwise on the right track with JsonIgnore With JsonIgnore on all of the same-named methods to be ignored, the one to use does not need the JsonProperty annotation.
It's not necessary to change the name of the setter method to avoid ambiguity. You're otherwise on the right track with @JsonIgnore. With @JsonIgnore on all of the same-named methods to be ignored, the one to use does not need the @JsonProperty annotation.
Here's a simple example to demonstrate this point. Input. Json: {"value":"forty-two"} Foo.
Java: import java.io. File; import org.codehaus.jackson.annotate. JsonIgnore; import org.codehaus.jackson.map.
ObjectMapper; public class Foo { String value; public String getValue() {return value;} public void setValue(String value) {this. Value = value;} @JsonIgnore public void setValue(int value) {this. Value = String.
ValueOf(value);} public static void main(String args) throws Exception { ObjectMapper mapper = new ObjectMapper(); Foo foo = mapper. ReadValue(new File("input. Json"), Foo.
Class); System.out. Println(mapper. WriteValueAsString(foo)); } } If you don't want to alter the pristine POJO defs with a Jackson annotation, then you can use a MixIn.
Import java.io. File; import org.codehaus.jackson.annotate. JsonIgnore; import org.codehaus.jackson.map.
ObjectMapper; public class Foo { String value; public String getValue() {return value;} public void setValue(String value) {this. Value = value;} public void setValue(int value) {this. Value = String.
ValueOf(value);} public static void main(String args) throws Exception { ObjectMapper mapper = new ObjectMapper(); mapper. GetDeserializationConfig(). AddMixInAnnotations(Foo.
Class, IgnoreFooSetValueIntMixIn. Class); Foo foo = mapper. ReadValue(new File("input.
Json"), Foo. Class); System.out. Println(mapper.
WriteValueAsString(foo)); } } abstract class IgnoreFooSetValueIntMixIn { @JsonIgnore public abstract void setValue(int value); }.
Thanks, this is exactly what I was looking for. – gwhitake Jun 14 '11 at 23:00.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.