In a config modifier schema, use prefer to specify which value to return when evaluating an array of property definitions. If the specified prefer value exists, it's returned, otherwise the next property is evaluated.
This is useful for common situations when there are multiple possible fields from the input that might be relevant to the output, and you want to choose the “best” from that list.
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’re receiving an ADT^02 message where Visit.VisitDateTime is normally mapped from PV1.44.1 but is sometimes null or doesn’t exist. However, you still want to map a value from PV2.8.1 as a backup. This is a perfect use case for prefer. If the first choice is null or missing, the schema automatically falls back to the second, third, or Nth choice.
Based on this example config modifier schema, this is the output.