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

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -