Examples

Example configuration snippets

Demo configuration with inclusion and expansion

Assume the following directories/files:

/
+ server/
  + config/
    + config.json
    + includes/
      + globals.json
      + modules/
        + mod01.json
        + mod02.json
+ demo/
  + file01
  + file02  
config/config.json
{
    "globals": "@include:includes/globals.json",
    "modules": "@include:includes/modules"
}
config/includes/globals.json
{
    "demo_dir": "/demo"
}
config/includes/modules/mod01.json
{
    "name": "DemoModule",
    "enabled": true,
    "config": {
        "path": "${globals.demo_dir}/file01"
    }
}
config/includes/modules/mod02.json
{
    "name": "DemoModule",
    "enabled": true,
    "config": {
        "path": "${globals.demo_dir}/file02"
    }
}

When inclusion and expansion is performed, config.json will have the following content:

{
    "globals": {
        "base_dir": "/server"
    },
    "modules": [
        {
            "name": "DemoModule",
            "enabled": true,
            "config": {
                "path": "/demo/file01"
            }
        },
        {
            "name": "DemoModule",
            "enabled": true,
            "config": {
                "path": "/demo/file02"
            }
        }
    ]
}

Note that:

  • globals.json include was expanded to an object

  • modules include was expanded to an array containing each of the JSON files in the directory as elements

  • all expansion expressions (${globals.demo_dir}) are replaced with the property value ("/demo")

Last updated