public class GroupFan<T> { private Long id; private String name; private List<T> users = new ArrayList<T>(); }
}GroupFan<User> group3 = JSON.parseObject(jsonString, GroupFan<User>.class);这种写法会报错,fastjson支持解析泛型吗
GroupFan<User> group3 = JSON.parseObject(jsonString, GroupFan<User>.class);
tp5buhyn1#
GroupFan<User> group3 = JSON.parseObject(jsonString, new TypeReference<GroupFan<User>>(){});这种方式反序列化后,里面的users的size永远都是0,这是为何?@wenshao
GroupFan<User> group3 = JSON.parseObject(jsonString, new TypeReference<GroupFan<User>>(){});
1条答案
按热度按时间tp5buhyn1#
GroupFan<User> group3 = JSON.parseObject(jsonString, new TypeReference<GroupFan<User>>(){});
这种方式反序列化后,里面的users的size永远都是0,这是为何?
@wenshao