private static JsonObject deepCopyObj(JsonObject from) { JsonObject result = new JsonObject(); for (Map.Entry<String, JsonElement> entry : from.entrySet()) { result.add(entry.getKey(), deepCopy(entry.getValue())); } return result; }
static void modified() { try (FileWriter writer = new FileWriter(getFile())) { JsonObject obj = deepCopy(INSTANCE.everythingElse); obj.addProperty("clientToken", INSTANCE.clientToken); obj.add("authenticationDatabase", GSON.toJsonTree(INSTANCE.authenticationDatabase.profiles)); GSON.toJson(obj, writer); System.out.println("Profiles saved"); } catch (IOException e) { e.printStackTrace(); } }