fixed json to jsonc and added two example configs for testing

master
Moritz 2026-11-15 14:37:08 +01:00
parent 0cca0384c9
commit aa6d513ca2
6 changed files with 41 additions and 5 deletions

15
example.jsonc 100644
View File

@ -0,0 +1,15 @@
{
// Example application configuration for testing.
"application": {
"name": "Config Editor Example",
"environment": "development"
},
"server": {
"host": "localhost",
"port": 8080
},
"features": {
"logging": true,
"maintenanceMode": false
}
}

15
example.xml 100644
View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<application>
<name>Config Editor Example</name>
<environment>development</environment>
</application>
<server>
<host>localhost</host>
<port>8080</port>
</server>
<features>
<logging>true</logging>
<maintenanceMode>false</maintenanceMode>
</features>
</configuration>

View File

@ -4,7 +4,7 @@ public class config_editor {
static java.io.File config_file;
enum ConfigFileType {
JSON,
JSONC,
XML
}
@ -29,14 +29,14 @@ public class config_editor {
}
static void config_file_type() {
if (config_file_path.endsWith(".json")) {
config_file_type = ConfigFileType.JSON;
System.out.println("JSON config file detected.");
if (config_file_path.endsWith(".jsonc")) {
config_file_type = ConfigFileType.JSONC;
System.out.println("JSONC config file detected.");
} else if (config_file_path.endsWith(".xml")) {
config_file_type = ConfigFileType.XML;
System.out.println("XML config file detected.");
} else {
System.err.println("Unsupported config file type. Please provide a .json or .xml file.");
System.err.println("Unsupported config file type. Please provide a .jsonc or .xml file.");
}
}

View File

View File

@ -0,0 +1,3 @@
public class jsonc_parse {
}

View File

@ -0,0 +1,3 @@
public class xml_parse {
}