I want to automate YAML file processing using snake YAML
Input:
_Function: &_Template
Name: A
Address: B
_Service: &_Service
Problem1:
<<: *_Template
Problem2:
<<: *_Template
Function.Service:
Service1:
<<: *_Service
Service2:
<<: *_Service
After Modifying the desired output is
_Function: &_Template
Name: A
Address: B
_Service: &_Service
Problem1:
<<: *_Template
Problem2:
<<: *_Template
Function.Service:
Service1:
<<: *_Service
Service2:
<<: *_Service
Service2:
<<: *_Service
Is it possible to modify file with out disturbing Anchors & aliases, I tried to read Yaml file and write it into different file, the output file contains Map objects in form key value pairs. But how to write output file with anchors & Aliases
Yaml yaml = new Yaml();
Map<String, Object> tempList = (Map<String, Object>)yaml.load(new FileInputStream(new File("/Users/Lakshmi/Downloads/test_input.yml")));
Yaml yamlwrite = new Yaml();
FileWriter writer = new FileWriter("/Users/Lakshmi/Downloads/test_output.yml");
yamlwrite.dump(tempList, writer);
If not snakeYaml, is there any language where-in we can auto modify yaml files without disturbing anchors & aliases.