先看一个yml的实例(此示例来自在线验证yml:https://qqe2.com/json2yaml)
---# Collection Types ############################################################################################################################################## http://yaml.org/type/map.html -----------------------------------------------#map: # Unordered set of key: value pairs. Block style: !!map Clark : Evans Ingy : döt Net Oren : Ben-Kiki Flow style: !!map { Clark: Evans, Ingy: döt Net, Oren: Ben-Kiki }# http://yaml.org/type/omap.html ----------------------------------------------#omap: # Explicitly typed ordered map (dictionary). Bestiary: !!omap - aardvark: African pig-like ant eater. Ugly. - anteater: South-American ant eater. Two species. - anaconda: South-American constrictor snake. Scaly. # Etc. # Flow style Numbers: !!omap [ one: 1, two: 2, three : 3 ]# http://yaml.org/type/pairs.html ---------------------------------------------#pairs: # Explicitly typed pairs. Block tasks: !!pairs - meeting: with team. - meeting: with boss. - break: lunch. - meeting: with client. Flow tasks: !!pairs [ meeting: with team, meeting: with boss ]
对应的结果,
{ map: { 'Block style': { Clark: 'Evans', Ingy: 'döt Net', Oren: 'Ben-Kiki' }, 'Flow style': { Clark: 'Evans', Ingy: 'döt Net', Oren: 'Ben-Kiki' } }, omap: { Bestiary: [ { aardvark: 'African pig-like ant eater. Ugly.' }, { anteater: 'South-American ant eater. Two species.' }, { anaconda: 'South-American constrictor snake. Scaly.' } ], Numbers: [ { one: 1 }, { two: 2 }, { three: 3 } ] }, pairs: { 'Block tasks': [ [ 'meeting', 'with team.' ], [ 'meeting', 'with boss.' ], [ 'break', 'lunch.' ], [ 'meeting', 'with client.' ] ], 'Flow tasks': [ [ 'meeting', 'with team' ], [ 'meeting', 'with boss' ] ] } }
实际的对比图如下
![f749864d037dbd281c4f9c3c18e0b295.png](https://img-blog.csdnimg.cn/img_convert/f749864d037dbd281c4f9c3c18e0b295.png)
yml实例一
说明这个实例也是为了展示我今天的配置准备做的配置做了引子,我今天准备在yml中实现数组+map的形式,最终映射到我们自己的bean中。
![05c15e5dce997f1ca32e1d4d333cdbcb.png](https://img-blog.csdnimg.cn/img_convert/05c15e5dce997f1ca32e1d4d333cdbcb.png)
最终通过springboot实现,映射到bean中即可
![596feda4a9936bb4143536fb33544759.png](https://img-blog.csdnimg.cn/img_convert/596feda4a9936bb4143536fb33544759.png)
![e06a058b472420bb513bed8a58b1d888.png](https://img-blog.csdnimg.cn/img_convert/e06a058b472420bb513bed8a58b1d888.png)
![04f0b4d18b0294a5c2417b03cfb3aac9.png](https://img-blog.csdnimg.cn/img_convert/04f0b4d18b0294a5c2417b03cfb3aac9.png)
参考地址:
1、https://blog.csdn.net/qq_33524158/article/details/79600434
2、https://qqe2.com/json2yaml