I intend to store multiple java objects into a JSON file but I got no clue how to do so. That's my code :
private static final String JSONFILEPATH = "config.json";
public void addSavefile(Savefile sf){
ObjectMapper mapper = new ObjectMapper();
try{
mapper.writeValue(new File(JSONFILEPATH), sf);
} catch (JsonGenerationException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
But it works just once, after I try to add more objects it just deletes the last one stored and replaces it with the new one.