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 T map(S source, Class classType) throws IOException { ObjectMapper objectMapper = new ObjectMapper(); String jsonString = objectMapper.writeValueAsString(source); return objectMapper.readValue(jsonString, classType); } }