Jsony Config
Jsony Config is an opinionated application/service configuration framework based on jsony
Features
- Fast compile times.
- Lenient Json Configs Supporting
- Trailing Commas
- Comments
- Unquoted static keys
- Loading from multiple config files with priority.
- Resolving paths relative to the location of the config file.
- Warnings for duplicate and unused fields, localized to the specific file and line.
- Various search strategies for finding configs.
- Lazy initialized global config, useable from tests.
Configuration Formats
Two configuration file formats are supported: .json and .js.
JSON (.json)
The .json format supports lenient features like trailing commas and comments, which can be useful for configuration files. However, editor support for these extensions to the JSON standard can be inconsistent and may require special configuration.
// application.config.json
JavaScript (.js)
To provide a better out-of-the-box editor experience with syntax highlighting and validation for lenient JSON features, a .js format is also supported.
This format is a workaround that uses a subset of JavaScript syntax.
The configuration must be assigned to a const CONFIG = declaration. jsony_config will locate this line and parse the object that follows.
// application.config.js
const CONFIG = ;
Note: While this looks like JavaScript, it is not executed as such. JavaScript features like variables, functions, or arithmetic are not supported. This approach is simply a "hack" to leverage editor support for JavaScript object literals, which closely resembles the lenient JSON syntax.
Example
use ;
static CONFIG: = new;