[*] 3.0.0正式版本

This commit is contained in:
acgist
2022-12-02 07:32:57 +08:00
parent fe7e48ec0e
commit 1ffe4f5bee
3 changed files with 33 additions and 36 deletions

View File

@@ -105,6 +105,27 @@ public final class JSONUtils {
throw MessageCodeException.of(e, "JSON转Java失败" + json);
}
}
/**
* JSON转Java
*
* @param <T> Java类型
*
* @param json JSON
* @param type Java类型
*
* @return Java
*/
public static final <T> T toJava(String json, TypeReference<T> type) {
if (Objects.isNull(json) || Objects.isNull(type)) {
return null;
}
try {
return MAPPER.readValue(json, type);
} catch (IOException e) {
throw MessageCodeException.of(e, "JSON转Java失败" + json);
}
}
/**
* JSON转Map