bookmark

java - Use Jackson to write yaml? - Stack Overflow


Description

For v2.8.3 the following should work:

YAMLFactory yf = new YAMLFactory(); ObjectMapper mapper = new ObjectMapper(yf); ObjectNode root = (ObjectNode) mapper.readTree(yamlFileIn); // modify root here
FileOutputStream fos = new FileOutputStream(yamlFileOut); SequenceWriter sw = mapper.writerWithDefaultPrettyPrinter().writeValues(fos); sw.write(root);

Preview

Tags

Users

  • @jil

Comments and Reviews