Created
October 22, 2018 22:41
-
-
Save yarikoptic/da5a4f77ecf9d2d5ad86de7e070fe64b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# An example from https://en.wikipedia.org/wiki/YAML#Advanced_components | |
# pretty printed as .json after "expansion": | |
$> cat /tmp/sample.yaml | |
# 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 | |
spotSize: 2mm # redefines just this key, refers rest from &id001 | |
- step: *id002 | |
$> python -c 'import yaml, json; print(json.dumps(yaml.load(open("/tmp/sample.yaml")), indent=2))' | |
[ | |
{ | |
"step": { | |
"pulseEnergy": 5.4, | |
"instrument": "Lasik 2000", | |
"repetition": 1000, | |
"spotSize": "1mm", | |
"pulseDuration": 12 | |
} | |
}, | |
{ | |
"step": { | |
"pulseEnergy": 5.0, | |
"instrument": "Lasik 2000", | |
"repetition": 500, | |
"spotSize": "2mm", | |
"pulseDuration": 10 | |
} | |
}, | |
{ | |
"step": { | |
"pulseEnergy": 5.4, | |
"instrument": "Lasik 2000", | |
"repetition": 1000, | |
"spotSize": "1mm", | |
"pulseDuration": 12 | |
} | |
}, | |
{ | |
"step": { | |
"pulseEnergy": 5.0, | |
"instrument": "Lasik 2000", | |
"repetition": 500, | |
"spotSize": "2mm", | |
"pulseDuration": 10 | |
} | |
}, | |
{ | |
"step": { | |
"pulseEnergy": 5.4, | |
"instrument": "Lasik 2000", | |
"repetition": 1000, | |
"spotSize": "2mm", | |
"pulseDuration": 12 | |
} | |
}, | |
{ | |
"step": { | |
"pulseEnergy": 5.0, | |
"instrument": "Lasik 2000", | |
"repetition": 500, | |
"spotSize": "2mm", | |
"pulseDuration": 10 | |
} | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment