Optimize WebUtils.java
This commit is contained in:
@@ -24,7 +24,6 @@ import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.*;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
|
||||
import we.util.Consts.DP;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -89,6 +88,14 @@ public abstract class JacksonUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T readValue(byte[] bytes, Class<T> clz) {
|
||||
try {
|
||||
return m.readValue(bytes, clz);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String writeValueAsString(Object value) {
|
||||
try {
|
||||
return m.writeValueAsString(value);
|
||||
@@ -96,6 +103,14 @@ public abstract class JacksonUtils {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] writeValueAsBytes(Object value) {
|
||||
try {
|
||||
return m.writeValueAsBytes(value);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DateDeseralizer extends JsonDeserializer<Date> {
|
||||
|
||||
Reference in New Issue
Block a user