The problem with your code is that you are trying to access the object Map.Entry 'file'as a list. Here the item 'Stack'in your yaml data is a list containing two Maps. So the correct way to change the value is:
map.Stack[0].file = 'changeclass.py'
, dump(). :
DumperOptions options = new DumperOptions()
options.setPrettyFlow(true)
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK)
yaml = new Yaml(options)
yaml.dump(map, new FileWriter(<filePath>))
:
Date: 2001-11-23T20:03:17Z
User: ed
Fatal: Unknown variable "bar"
Stack:
- file: changeclass.py
line: 23
code: |
x = MoreObject("345\n")
- file: MoreClass.py
line: 58
code: foo = bar