The following example demonstrates how @hapipal/confidence resolves a configuration object based on provided criteria.
Input Configuration
{
"key1": "abc",
"key2": {
"$filter": "env",
"production": {
"deeper": {
"$value": "value"
}
},
"$default": {
"$filter": "platform",
"android": 0,
"ios": 1,
"$default": 2
}
},
"key3": {
"sub1": 123,
"sub2": {
"$filter": "xfactor",
"yes": 6
}
},
"ab": {
"$filter": "random.a",
"$range": [
{ "limit": 10, "value": 4 },
{ "limit": 20, "value": 5 }
],
"$default": 6
},
"$meta": {
"description": "example file"
}
}
Scenario 1: No criteria applied
When no criteria are provided, the configuration resolves to its default values:
{
"key1": "abc",
"key2": 2,
"key3": {
"sub1": 123
},
"ab": 6
}
Scenario 2: With criteria applied
If the following criteria are applied:
{
"env": "production",
"platform": "ios",
"xfactor": "yes",
"random": {
"a": 15
}
}
The configuration resolves to:
{
"key1": "abc",
"key2": {
"deeper": "value"
},
"key3": {
"sub1": 123,
"sub2": 6
},
"ab": 5
}