mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-22 16:03:15 +00:00
fromJson実装 WIP
This commit is contained in:
parent
e07cbda769
commit
e9b7ad4d92
|
@ -44,12 +44,22 @@ public class JsonUtils {
|
||||||
throw new IllegalArgumentException("Unknown object type");
|
throw new IllegalArgumentException("Unknown object type");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Object fromJson(String json, ActionType actionType) {
|
||||||
public static <T> T fromJson(String json, ActionType actionType, Class<T> clazz) {
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
return null;
|
try {
|
||||||
|
switch (actionType) {
|
||||||
|
case INSERT_PAGE:
|
||||||
|
return mapper.readValue(json, InsertPage.class);
|
||||||
|
case UPDATE_PAGE:
|
||||||
|
return mapper.readValue(json, UpdatePage.class);
|
||||||
|
case DELETE_PAGE:
|
||||||
|
return mapper.readValue(json, DeletePage.class);
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Unknown action type");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Internal methods
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user