How to flatten the YAML structure (List/Map)

Viewed 57

Is it possible to convert hierarchical attributes(Map/List) to flattened as linear YAML structure?

For instance, there is a below property defined in a microservice:

default:  
  app:
    authentication: 
      security: ${app.authentication.security}

The above can be overridden using kube object i.e. configMap and as the above property exposed as ${app.authentication.security}, so inside configMap we aren't required to define the entire structure(shown as below), so here we have flattered the YAML hierarchy. We are not required to define the entire order.

app.authentication.security: false 

Now, is there any possibility to flatter the YAML Map/List, and those Map/List properties can be dynamic. Below is the sample structure.

Example:

app-ex:
  list: 
    - key1: value
      key2: value
      key3: 
        - list1
        - list2
        - list3
    - key4: value
      key5: value
      key6: 
        - list1
        - list2
        - list3
    .
    .
    - key N

The possible expected output can be a flat pattern as below:

app-ex.list.key1: val1
app-ex.list.key2: val2
0 Answers
Related