SIMPLE_CONFIG
JSON-based configuration file management with dot-notation access.
Inherits from: SIMPLE_JSON_CONSTANTS
Creation
| Feature |
Signature |
Description |
make |
|
Create empty configuration. |
make_with_file |
(a_file_path: STRING) |
Create configuration from JSON file. |
Contract: make_with_file
make_with_file (a_file_path: STRING)
require
path_not_empty: not a_file_path.is_empty
Access
| Feature |
Signature |
Description |
file_path |
: STRING |
Path to configuration file. |
is_modified |
: BOOLEAN |
Has configuration been modified since last save? |
has_key |
(a_key: STRING): BOOLEAN |
Does configuration have key? Supports dot notation. |
Contract: has_key
has_key (a_key: STRING): BOOLEAN
require
key_not_empty: not a_key.is_empty
String Access
| Feature |
Signature |
Description |
string_value |
(a_key: STRING): detachable STRING |
Get string value for key. Supports dot notation. |
string_value_or_default |
(a_key, a_default: STRING): STRING |
Get string value or default if not found. |
string_value_or_env |
(a_key, a_env_var: STRING): detachable STRING |
Get from config or environment variable. |
string_value_or_env_or_default |
(a_key, a_env_var, a_default: STRING): STRING |
Get from config, then env, then default. |
Contract: string_value
string_value (a_key: STRING): detachable STRING
require
key_not_empty: not a_key.is_empty
Contract: string_value_or_env
string_value_or_env (a_key, a_env_var: STRING): detachable STRING
require
key_not_empty: not a_key.is_empty
env_var_not_empty: not a_env_var.is_empty
Integer Access
| Feature |
Signature |
Description |
integer_value |
(a_key: STRING): INTEGER |
Get integer value (0 if not found). |
integer_value_or_default |
(a_key: STRING; a_default: INTEGER): INTEGER |
Get integer value or default. |
integer_value_or_env |
(a_key, a_env_var: STRING; a_default: INTEGER): INTEGER |
Get from config, parse env var, or use default. |
Boolean Access
| Feature |
Signature |
Description |
boolean_value |
(a_key: STRING): BOOLEAN |
Get boolean value (False if not found). |
boolean_value_or_default |
(a_key: STRING; a_default: BOOLEAN): BOOLEAN |
Get boolean value or default. |
Real Access
| Feature |
Signature |
Description |
real_value |
(a_key: STRING): DOUBLE |
Get real value (0.0 if not found). |
real_value_or_default |
(a_key: STRING; a_default: DOUBLE): DOUBLE |
Get real value or default. |
Array Access
| Feature |
Signature |
Description |
string_list |
(a_key: STRING): ARRAYED_LIST [STRING] |
Get array of strings for key. |
integer_list |
(a_key: STRING): ARRAYED_LIST [INTEGER] |
Get array of integers for key. |
real_list |
(a_key: STRING): ARRAYED_LIST [DOUBLE] |
Get array of reals for key. |
Section Access
| Feature |
Signature |
Description |
section |
(a_key: STRING): detachable SIMPLE_CONFIG |
Get nested section as separate config object. |
Contract: section
section (a_key: STRING): detachable SIMPLE_CONFIG
require
key_not_empty: not a_key.is_empty
Element Change
| Feature |
Signature |
Description |
set_string |
(a_key, a_value: STRING) |
Set string value for key. |
set_integer |
(a_key: STRING; a_value: INTEGER) |
Set integer value for key. |
set_boolean |
(a_key: STRING; a_value: BOOLEAN) |
Set boolean value for key. |
set_real |
(a_key: STRING; a_value: DOUBLE) |
Set real value for key. |
set_section |
(a_key: STRING; a_section: SIMPLE_CONFIG) |
Set nested section for key. |
remove |
(a_key: STRING) |
Remove value for key. |
Contract: set_string
set_string (a_key, a_value: STRING)
require
key_not_empty: not a_key.is_empty
ensure
modified: is_modified
Note: Setting does NOT support dot notation. Use set_section for nested values.
File Operations
| Feature |
Signature |
Description |
load |
|
Load configuration from file. |
merge_file |
(a_file_path: STRING) |
Merge another config file, overriding existing values. |
save |
|
Save configuration to file. |
save_to |
(a_file_path: STRING) |
Save configuration to specified file. |
Contract: save
save
require
has_file_path: not file_path.is_empty
ensure
not_modified: not is_modified
Contract: save_to
save_to (a_file_path: STRING)
require
path_not_empty: not a_file_path.is_empty
ensure
path_set: file_path = a_file_path
not_modified: not is_modified
Contract: merge_file
merge_file (a_file_path: STRING)
require
path_not_empty: not a_file_path.is_empty
Output
| Feature |
Signature |
Description |
to_json |
: STRING |
Convert configuration to compact JSON string. |
to_json_pretty |
: STRING |
Convert configuration to formatted JSON string. |
Dot Notation Reference
All read operations support dot notation for nested access:
| Key |
JSON Path |
"host" |
Top-level "host" key |
"database.host" |
database -> host |
"app.server.port" |
app -> server -> port |
Note: Write operations (set_*) do NOT support dot notation. Build nested structures using set_section.