mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-22 01:11:40 +00:00
Camera de/serialization, folder management
This commit is contained in:
@@ -27,18 +27,16 @@ public class FileHelper {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Serializer(Object object, Path path) throws IOException {
|
||||
File file = new File(path.toString());
|
||||
PolymorphicTypeValidator ptv = BasicPolymorphicTypeValidator.builder().allowIfBaseType(Object.class).build();
|
||||
ObjectMapper objectMapper = JsonMapper.builder().activateDefaultTyping(ptv, ObjectMapper.DefaultTyping.JAVA_LANG_OBJECT).build();
|
||||
objectMapper.writeValue(file,object);
|
||||
objectMapper.writeValue(new File(path.toString()), object);
|
||||
}
|
||||
|
||||
public static Object DeSerializer(Path path,Class<?> ref) throws IOException {
|
||||
File file = new File(path.toString());
|
||||
public static <T> T DeSerializer(Path path, Class<T> ref) throws IOException {
|
||||
PolymorphicTypeValidator ptv = BasicPolymorphicTypeValidator.builder().allowIfBaseType(Object.class).build();
|
||||
ObjectMapper objectMapper = JsonMapper.builder().activateDefaultTyping(ptv, ObjectMapper.DefaultTyping.JAVA_LANG_OBJECT).build();
|
||||
Object o = objectMapper.readValue(file, ref);
|
||||
return o;
|
||||
return objectMapper.readValue(new File(path.toString()), ref);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user