- apps/lotteryServer, lotteryCapture, lotteryOpen 三个业务工程 - 忽略 archive/, tools/, infra/data/ 大目录与敏感配置文件 - 移除 lotteryServer 原嵌套 git,并入顶层统一管理
33 lines
692 B
Java
33 lines
692 B
Java
package javautils.json;
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
public class JacksonUtil {
|
|
|
|
public static String toJSON(Object o) {
|
|
try {
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
return objectMapper.writeValueAsString(o);
|
|
} catch (JsonProcessingException e) {
|
|
e.printStackTrace();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static <T> T toObject(String json, Class<T> clazz) {
|
|
try {
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
return objectMapper.readValue(json, clazz);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
|
|
}
|
|
|
|
}
|