java - Polymorphic deserialization in Jackson based on ints, not strings -
normally, when doing polymorphic deserialization jackson, have string field maps class, , can this.
@jsontypeinfo( use = jsontypeinfo.id.name, include = jsontypeinfo.as.property, property = "methodname") @jsonsubtypes({ @jsonsubtypes.type(value = myfirstclass.class, name = "firstclassname"), @jsonsubtypes.type(value = mysecondclass.class, name = "secondclassname")})
i can't find easy example of how if value integer, rather string. instance, how pick class deserialize if instead of "methodname":"firstclassname" json included "methodname":1?
there no 'easy' way of doing that. have write own implementation of serialization mechanicsm, , 1 deserialization. perils of such implementation many you'd better off quoting typeinfo property , using string.
Comments
Post a Comment