| 123456789101112131415161718 |
- package com.lightinit.hsdatashow.common;
- import com.fasterxml.jackson.databind.ObjectMapper;
- import java.io.IOException;
- /**
- * Created by WangYao on 2018/5/23.
- */
- public class ObjectMappingUtils {
- public static <S, T> T map(S source, Class<T> classType) throws IOException {
- ObjectMapper objectMapper = new ObjectMapper();
- String jsonString = objectMapper.writeValueAsString(source);
- return objectMapper.readValue(jsonString, classType);
- }
- }
|