Jackson - Deserialising JSON string - TypeReference vs TypeFactory.constructCollectionType Jackson - 反序列化JSON字符串 - TypeReference vs TypeFactory.constructCollectionType
- 论坛
- Jackson - Deserialising JSON string - TypeReference vs TypeFactory.constructCollectionType Jackson - 反序列化JSON字符串 - TypeReference vs TypeFactory.constructCollectionType
6 浏览
Jackson - Deserialising JSON string - TypeReference vs TypeFactory.constructCollectionType Jackson - 反序列化JSON字符串 - TypeReference vs TypeFactory.constructCollectionType
将JSON字符串反序列化为类的列表有多种不同的方法,可以在StackOverflow问题中找到。以下是两种不同的实现方式:
类型1(文档链接):
ListsomeClassList = mapper.readValue(jsonString, typeFactory.constructCollectionType(List.class, SomeClass.class));
类型2(文档链接):
Listlist = mapper.readValue(jsonString, new TypeReference >() { });
尽管上述两种类型都可以完成任务,但这些实现之间有何区别?