How do I can create a list in yaml file?
I have below application.conf file.
mappings = [
{
partnerId = "partner1"
stagePolicyMapping = [
{ stage = "Assignment Call",
policy = "underwriting"
},
{ stage = "Collect Docs",
policy = "collectverify"
},
{ stage = "Partial Application",
policy = "partialapp"
}
]
},
{
partnerId = "partner2"
stagePolicyMapping = [
{ stage = "Application Received",
policy = "appreceivedusa"
},
{ stage = "Application Incomplete",
policy = "incompleteapp"
},
{ stage = "Partial Application",
policy = "partialapp"
}
]
}
I want to switch to application.yml file. Below is what I have so far. I am not sure how to create list of stage and policy properties.
# policy mappings
mappings:
partnerId:
partner1:
stage: Assignment Call
policy: underwriting
???? stage and policy again ?
If you look at the documentation of YAML, it starts with a preview which immediately shows example of a list (aka a sequence ):
Example 2.4. Sequence of Mappings
(players' statistics)- name: Mark McGwire hr: 65 avg: 0.278 - name: Sammy Sosa hr: 63 avg: 0.288
So you data should be:
mappings:
-
partnerId: partner1
stagePolicyMapping:
-
stage: Assignment Call
policy: underwriting
-
stage: Collect Docs
policy: collectverify
-
stage: Partial Application
policy: partialapp
-
partnerId: partner2
stagePolicyMapping:
-
stage: Application Received
policy: appreceivedusa
-
stage: Application Incomplete
policy: incompleteapp
-
stage: Partial Application
policy: partialapp
You can also do it more compact as shown in answer by michalk .
Something like :
mappings:
- partnerId: partner1
stagePolicyMapping:
- stage: Assignment Call
policy: underwriting
- stage: Collect Docs
policy: collectverify
- stage: Partial Application
policy: partialapp
- partnerId: partner2
stagePolicyMapping:
- stage: Application Received
policy: appreceivedusa
- stage: Application Incomplete
policy: incompleteapp
- stage: Partial Application
policy: partialapp
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.