Package com.dennisturco
Class JsonConfig
java.lang.Object
com.dennisturco.JsonConfig
A utility class to load and flatten JSON configuration files into a flat key-value map.
This class reads a JSON configuration file and flattens nested structures into a single-level
HashMap with concatenated keys (e.g., "MenuItems_BugReport"). It supports reloading and accessing
individual configuration values by key.
-
Constructor Summary
ConstructorsConstructorDescriptionJsonConfig
(String filePath) Constructs a new JsonConfig with the specified file path. -
Method Summary
Modifier and TypeMethodDescriptiongetConfigByKey
(String key) Returns a configuration value by key.Returns the full map of flattened configuration values.void
Prints all configuration key-value pairs to the standard output.void
Reloads the configuration file and updates the internal config map.
-
Constructor Details
-
JsonConfig
Constructs a new JsonConfig with the specified file path.- Parameters:
filePath
- The path to the JSON configuration file.- Throws:
IOException
- if the file cannot be read.
-
-
Method Details
-
getConfigByKey
-
getConfigs
-
printAllConfigs
public void printAllConfigs()Prints all configuration key-value pairs to the standard output. -
reloadConfigs
Reloads the configuration file and updates the internal config map.- Throws:
IOException
- if the file cannot be read.
-