Overview
SIMPLE_YAML_QUICK provides one-liner YAML config file access with
dot-path notation. Perfect for reading configuration files like database.host.
For YAML building and advanced features, use SIMPLE_YAML directly.
Quick Start
local
yaml: SIMPLE_YAML_QUICK
config: YAML_VALUE
do
create yaml.make
config := yaml.load ("config.yml")
host := yaml.get_string (config, "database.host")
port := yaml.get_integer (config, "database.port")
debug := yaml.get_boolean (config, "logging.debug")
timeout := yaml.get_real (config, "server.timeout")
across yaml.get_list (config, "features.enabled") as f loop
print (f)
end
host := yaml.string_from_file ("config.yml", "database.host")
port := yaml.integer_from_file ("config.yml", "database.port")
if yaml.has_key (config, "database.ssl") then ...
config := yaml.parse (yaml_string)
if yaml.is_valid (yaml_string) then ...
if yaml.has_error then
print (yaml.last_error)
end
end
Example Config File
database:
host: localhost
port: 5432
name: myapp
logging:
level: info
debug: false
features:
enabled:
- auth
- cache
- api
yaml.get_string (config, "database.host")
yaml.get_integer (config, "database.port")
yaml.get_boolean (config, "logging.debug")
yaml.get_list (config, "features.enabled")
API Reference
Loading
| Feature | Description |
load (path) | Load YAML file |
parse (yaml_string) | Parse YAML string |
Dot-Path Getters
| Feature | Description |
get_string (value, path) | Get string at dot-path |
get_integer (value, path) | Get integer at dot-path |
get_real (value, path) | Get real number at dot-path |
get_boolean (value, path) | Get boolean at dot-path |
get_list (value, path) | Get string list at dot-path |
One-Liner File Access
| Feature | Description |
string_from_file (path, key) | Load file and get string |
integer_from_file (path, key) | Load file and get integer |
boolean_from_file (path, key) | Load file and get boolean |
Existence and Validation
| Feature | Description |
has_key (value, path) | Does path exist? |
is_valid (yaml_string) | Is string valid YAML? |
has_error | Did last operation fail? |
last_error | Last error message |