blademainer / blademainer.github.com

My blog of http://xiongyingqi.com. Source is https://github.com/blademainer/blog

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Jackson解析json为指定泛型的集合 | Blademainer

blademainer opened this issue · comments

https://blog.xiongyingqi.com/2016/03/29/jackson-deserialize-collection/

问题在日常开发中,当使用ObjectMapper进行解析json时,我们时常需要将json解析成我们指定泛型的集合类型Collection<type>。但是如果直接使用objectMapper.readValue(json, Collection.class)的话,那么就会解析为Collection<Map>的类型,这个明显不是我们想要的。方案在jackson内,如果要反序