java - jackson-mapper version 1.9.12 EnumDeserializer issue -
i trying map string enum object using jackson objectmapper.readvalue(string,class) api, problem lets json string contains task object action enum below
public enum action {
@xmlenumvalue("add") add("add"), @xmlenumvalue("amend") amend("amend"), @xmlenumvalue("delete") delete("delete"), @xmlenumvalue("pending") pending("pending"); private final string value; action(string v) { value = v; } public string value() { return value; } public static action fromvalue(string v) { (action c: action.values()) { if (c.value.equals(v)) { return c; } } throw new illegalargumentexception(v); } }
and jason string "{"action":"add"}" objectmapper.readvalue(jsonstring, task.class) throws
org.codehaus.jackson.map.deser.stddeserializationcontext.weirdstringexception(stddeserializationcontext.java:243) action add because cant convert enum.
i tried adding custom desiserializer, enumdeserializer getting called anyway. ideas?
all objects jaxb generated, annotations not possible.
thanks help
have tried:
new objectmapper().setannotationintrospector(new jaxbannotationintrospector()).readvalue()
Comments
Post a Comment