How can I write multiple fields in one line Loader=yaml.FullLoader?
Eg. turn this:
field:
item0: 0
item1: 1
into this:
field:
item0:0, item1:1
Or even:
field: {item0:0, item1:1}
Eg. in JSON you could do:
{"field":{ "item0":0, "item1":1 }}
How can you do the same thing in YAML?
YAML is designed to be a superset of JSON, so your JSON one-liner would also work with a YAML parser:
import yaml
print(yaml.load('{"field":{ "item0":0, "item1":1 }}', Loader=yaml.FullLoader))
and since the field names are all alphabets in your example, you can omit the quotes:
print(yaml.load('{field: {item0: 0,item1: 1}}', Loader=yaml.FullLoader))
both would produce the output:
{'field': {'item0': 0, 'item1': 1}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With