diff --git a/common/src/main/java/ctbrec/Config.java b/common/src/main/java/ctbrec/Config.java index 30e9570f..29da09a7 100644 --- a/common/src/main/java/ctbrec/Config.java +++ b/common/src/main/java/ctbrec/Config.java @@ -162,7 +162,8 @@ public class Config { String json = new String(fileContent, UTF_8).trim(); json = migrateJson(json); settings = Objects.requireNonNull(mapper.readValue(json, Settings.class)); - settings.filterNAcamsOnly = json.has("filterNAcamsOnly") ? json.getBoolean("filterNAcamsOnly") : false; + JSONObject jsonObject = new JSONObject(json); + settings.filterNAcamsOnly = jsonObject.optBoolean("filterNAcamsOnly", false); settings.httpTimeout = Math.max(settings.httpTimeout, 10_000); if (settings.recordingsDir.endsWith("/")) { @@ -259,9 +260,9 @@ public class Config { if (savingDisabled) { return; } - JSONObject json = new JSONObject(mapper.writeValueAsString(settings)); - json.put("filterNAcamsOnly", settings.filterNAcamsOnly); - String jsonString = json.toString(); + JSONObject jsonObject = new JSONObject(mapper.writeValueAsString(settings)); + jsonObject.put("filterNAcamsOnly", settings.filterNAcamsOnly); + String jsonString = jsonObject.toString(); File configFile = new File(configDir, filename); log.debug("Saving config to {}", configFile.getAbsolutePath()); Files.createDirectories(configDir.toPath());