How to Define array values in YAML and fetch the keys - Mule 4
00:23 25 Nov 2021

I'm trying to define the array in Mule YAML configuration to dynamically retrieve the key based on the value.

For example, I have a flow variable code= finance. Use code to loop through the list to fetch the key roles (below example). likewise, if the variable has 'emp1' should fetch the key employee.

Edited questions to give more clarity.

YAML configuration:

list:
  roles:
    - admin
    - finance
    - hr
    - sales
  employee:
    - emp1
    - emp2
    - emp3

Tried redefining the YAML file as described on this Page https://www.w3schools.io/file/yaml-multiline-arrays/ as below (see the --- to distinguish this as a list in YAML so that I can use (p('list') in dw to loop through. Mule did not like it either.

list:
---
  roles:
    - admin
    - finance
    - hr
    - sales
  employee:
    - emp1
    - emp2
    - emp3

Mule not liking it or how to define multi-line array and fetch the key dynamically? Any advice and thoughts?

Please let me know if the question is not clear. Thanks

yaml mule dataweave mule4