package com.yihu.jw.util.entity;

import com.fasterxml.jackson.databind.ObjectMapper;


public class EntityUtils {

    protected static ObjectMapper objectMapper = new ObjectMapper();

    public static <T> T jsonToEntity(String json,Class<T> target){
        T entity = null;
        try {
            entity  = objectMapper.readValue(json,target);
        } catch (Exception e) {
           throw new ServiceException("Json字符串转换成【"+target.getName()+"】实体类异常：" + e.getMessage());
        }
        return entity;
    }

}
