json转换指定对象

PageInfo<对象> pageInfo = JSON.parseObject(xxx, new TypeReference>() {});

如下写法有更好的性能

final static Type type = new TypeReference() {}.getType();

List<对象> list = JSON.parseObject("…", type);

object转换为指定对象
ObjectMapper objectMapper = new ObjectMapper();
Test test = objectMapper.convertValue(obj, Test.class);
引入com.fasterxml.jackson包

你可能感兴趣的:(code)