json

public static <T> List<T> toClassList(String json, Class<T> clazz) {
try {
List<T> retList = objectMapper.readValue(
json,
TypeFactory.defaultInstance().constructCollectionType(
List.class, clazz));
return retList;
} catch (Exception e) {
e.printStackTrace();
}
return null;

}


http://wiki.fasterxml.com/JacksonInFiveMinutes#Data_Binding_with_Generics

你可能感兴趣的:(json)