我想在YAML中重用哈希:
Defaults: &defaults
Company: Foo
Item: 123
Computer: *defaults
Price: 3000
Run Code Online (Sandbox Code Playgroud)
但是,这会产生错误.
是分别定位每个字段值的唯一途径是这样?
Defaults:
Company: &company Foo
Item: &item 123
Computer:
Company: *company
Item: *item
Price: 3000
Run Code Online (Sandbox Code Playgroud)
小智 253
尝试通过导入重新使用完整的组:
Defaults: &defaults
Company: foo
Item: 123
Computer:
<<: *defaults
Price: 3000
Run Code Online (Sandbox Code Playgroud)
文档:http://yaml.org/type/merge.html
zed*_*xff 18
# sequencer protocols for Laser eye surgery
---
- step: &id001 # defines anchor label &id001
instrument: Lasik 2000
pulseEnergy: 5.4
pulseDuration: 12
repetition: 1000
spotSize: 1mm
- step: &id002
instrument: Lasik 2000
pulseEnergy: 5.0
pulseDuration: 10
repetition: 500
spotSize: 2mm
- step: *id001 # refers to the first step (with anchor &id001)
- step: *id002 # refers to the second step
- step: *id001
- step: *id002
Run Code Online (Sandbox Code Playgroud)
来自维基百科的样本
| 归档时间: |
|
| 查看次数: |
24277 次 |
| 最近记录: |