I have a list of dict that looks like this
data = {'items': [{'id': '1', 'desc': 'Item 1', 'cat': 'cat1'}], 'categories': [{ 'id': 'cat1', 'desc': 'category number 1' }]}
I want to dump this in the following yaml format
---
items:
- { id: 'it1', desc: 'item number 1', cat: 'cat1' }
categories:
- { id: 'cat1', desc: 'category number 1' }
using yaml.dump(data)
outputs a yaml in the following format
categories:
- desc: category number 1
id: cat1
items:
- cat: cat1
desc: Item 1
id: '1'
What do I need to add to change this? I have tried setting the default_flow_style=False
with no difference.