I am parsing a java object into YAML using snakeyaml and snakeyaml is ordering alphabetically.
I want to use the order of nodes that are defined in the java object.
ex:
ClassB
String name;
String address;
String description;
ClassA classa;
This prints as
classb
address : ..
classa: ..
description: ..
name: ..
Expected Output
classb
name: ..
address : ..
description: ..
classa: ..
Code:
Representer representer = new Representer();
representer.getPropertyUtils().setSkipMissingProperties(true);
DumperOptions dumperOptions = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStype.BLOCK);
options.setPrettyFlow(true);
Yaml yaml = new Yaml (new Constructor(ClassC.class, representer, options)
How do i retain the order in YAML?