Fix and extend valueSubstitution Example

This commit is contained in:
Mike Bierlee 2022-09-29 02:10:45 +03:00
parent df3ccf8007
commit b45a616d29
2 changed files with 5 additions and 3 deletions

View file

@ -16,8 +16,9 @@ void main() {
// This example shows how values in configuration can be substituted from // This example shows how values in configuration can be substituted from
// environment variables or other configuration paths. // environment variables or other configuration paths.
environment["subject"] = "world"; environment["CONFIG_EXAMPLE_SUBJECT"] = "world";
auto config = loadJsonConfig("config.json"); auto config = loadJsonConfig("config.json");
writeln(config.get("greeting")); writeln(config.get("start")); // "Hello world! Enjoy your day!"
writeln(config.get("end")); // "Bye!"
} }

View file

@ -4,5 +4,6 @@
"subject": "$CONFIG_EXAMPLE_SUBJECT", "subject": "$CONFIG_EXAMPLE_SUBJECT",
"followUp": "${CONFIG_EXAMPLE_FOLLOW_UP:Enjoy your day!}" "followUp": "${CONFIG_EXAMPLE_FOLLOW_UP:Enjoy your day!}"
}, },
"greeting": "${parameters.greeting} ${parameters.subject}! ${parameters.followUp}" "start": "${parameters.greeting} ${parameters.subject}! ${parameters.followUp}",
"end": "${parameters.farewell:Bye!}"
} }