In a config modifier schema, use switch to check the value of a path against possible values that require different outcomes (i.e., returning a constant or parsing a different value).
Exclusive keywords
This keyword executes in the following order:
- omit
- constant
- references
- use
- get
- Mutually exclusive keywords at this level:
- properties
- if
- concat
- switch
- pipe
- merge
- prefer
- items
- default
- plugin
You can look at every observation code and shift the value from 0 to 1 for certain codes. If the code matches one of the cases, the schema then checks the observation’s Value against a nested switch statement.
Example: Switch input from initial payload
json
Example: Switch selector
json
For instance, if Observations[0].Code is 68520-6, it matches the second case. The nested switch then uses select: {} to look back at the original selector ($.Observations[*].Value). Because the Value is 1, the nested switch maps it to 2.
Example: Config modifier with switch keyword
yaml
Based on this example config modifier, the Value is now 2.
Example: Switch output from processed payload
json