I am writing a mixin to deserialize a string into javax.servlet.http.Cookie
Mixin.java
package a;
import org.codehaus.jackson.annotate.JsonProperty;
public abstract class MixIn {
MixIn(@JsonProperty("name") String name, @JsonProperty("value") String value) { }
}
HelloWorld.java
package b;
import a.MixIn;
ObjectMapper mapper = new ObjectMapper();
mapper.getDeserializationConfig().addMixInAnnotations(Cookie.class, MixIn.class);
Cookie aCookie = mapper.readValue("{"name":"abc","value":"xyz"}", Cookie.class);
It seems to provide "JsonMappingException: No suitable constructor found for type [simple type, class javax.servlet.http.Cookie]" error.
Please do note that
- Mixin is (has to be) defined as a separate class (NOT an inner class, not static)
- Mixin and the class where its used are (have to be) in 2 different packages.
I am using jackson 1.9.9