fix: 新增工作流模型

This commit is contained in:
yunlong.li
2021-11-17 18:48:40 +08:00
parent 89f51fe568
commit cfdf04981a
7 changed files with 275 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
@ -43,6 +44,14 @@ public class JsonUtils {
}
}
public static byte[] toJsonByte(Object object) {
try {
return objectMapper.writeValueAsBytes(object);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
public static <T> T parseObject(String text, Class<T> clazz) {
if (StrUtil.isEmpty(text)) {
return null;
@ -84,4 +93,20 @@ public class JsonUtils {
}
}
public static JsonNode readTree(String text) {
try {
return objectMapper.readTree(text);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static JsonNode readTree(byte[] text) {
try {
return objectMapper.readTree(text);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}