package com.yihu.jw.utils; import com.fasterxml.jackson.databind.ObjectMapper; public class EntityUtils { protected static ObjectMapper objectMapper = new ObjectMapper(); public static T jsonToEntity(String json,Class target){ T entity = null; try { entity = objectMapper.readValue(json,target); } catch (Exception e) { throw new RuntimeException("Json字符串转换成【"+target.getName()+"】实体类异常:" + e.getMessage()); } return entity; } }