Judge0: migrate from Gson to Jackson (#1729)
This commit is contained in:
parent
dd88b21bca
commit
3cf5561379
|
@ -2,19 +2,17 @@ package dev.langchain4j.code.judge0;
|
|||
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import static com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT;
|
||||
|
||||
class Json {
|
||||
|
||||
static final ObjectMapper OBJECT_MAPPER = new ObjectMapper()
|
||||
.enable(INDENT_OUTPUT)
|
||||
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||
|
||||
;
|
||||
|
||||
static String toJson(Object o) {
|
||||
try {
|
||||
return OBJECT_MAPPER.writeValueAsString(o);
|
||||
|
@ -30,12 +28,4 @@ class Json {
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
static <T> T fromJson(String json, TypeReference<T> type) {
|
||||
try {
|
||||
return OBJECT_MAPPER.readValue(json, type);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue