jackson - Jackson使用,String与对象互转
准备
// jackson转换工具
private static final ObjectMapper objectMapper = new ObjectMapper()
.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
使用
对象转json
String str = objectMapper.writeValueAsString(new MessageEntity());
json转对象
List<String> tidList = objectMapper.readValue(tidListSrt, new TypeReference<List<String>>() {});