im using Jackson object mapper to save a json file into a raspberry pi file file is ok and is filled with data until i unplug the power to it. after plugging it back and checking the file it is empty.
public static <T> void serialize(Path path, T object, Class<T> ref, StdSerializer<T> serializer) throws IOException {
ObjectMapper objectMapper = new ObjectMapper();
SimpleModule module = new SimpleModule();
module.addSerializer(ref, serializer);
objectMapper.registerModule(module);
objectMapper.writerWithDefaultPrettyPrinter().writeValue(new File(path.toString()), object);
}