mirror of
https://github.com/JonasunderscoreJones/ZtereoMUSIC.git
synced 2025-10-26 21:09:19 +01:00
change: clean up and update config to json 0.3
This commit is contained in:
parent
3e96100171
commit
b3ba0db42e
1 changed files with 4 additions and 6 deletions
|
|
@ -3,26 +3,24 @@ package codes.ztereohype.ztereomusic.database;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.shadew.json.Json;
|
import net.shadew.json.Json;
|
||||||
import net.shadew.json.JsonNode;
|
import net.shadew.json.JsonNode;
|
||||||
import net.shadew.json.JsonSyntaxException;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class Config {
|
public class Config {
|
||||||
|
private final static Json json5 = Json.json5();
|
||||||
private @Getter final Map<String, String> propreties = new HashMap<>();
|
private @Getter final Map<String, String> propreties = new HashMap<>();
|
||||||
private String path;
|
private String path;
|
||||||
|
|
||||||
public static Config loadFrom(String path) throws JsonSyntaxException, FileNotFoundException {
|
public static Config loadFrom(String path) throws IOException {
|
||||||
Config config = new Config();
|
Config config = new Config();
|
||||||
|
|
||||||
Json json5 = Json.json5();
|
|
||||||
JsonNode tree = json5.parse(new File(path));
|
JsonNode tree = json5.parse(new File(path));
|
||||||
|
|
||||||
config.path = path;
|
config.path = path;
|
||||||
|
|
||||||
for (String key : tree.keys()) {
|
for (String key : tree.keySet()) {
|
||||||
config.getPropreties().put(key, tree.get(key).asString());
|
config.getPropreties().put(key, tree.get(key).asString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue