java实体entity<----->map互转
一:entity转map
一句搞定,直接返回map对象:
import org.springframework.cglib.beans.BeanMap;
BeanMap.create(entityObj);
也可用jackson的ObjectMapper 转
二:map转实体类
Map<String,String> map = new LinkedHashMap<>();
ObjectMapper objectMapper = new ObjectMapper();
User user = objectMapper.convertValue(map, User.class);