A simple YAML generator for Java
For Gradle:
dependencies {
implementation group: 'io.github.devatherock', name: 'simple-yaml', version: '0.3.0'
}
For Maven:
<dependencies>
<dependency>
<groupId>io.github.devatherock</groupId>
<artifactId>simple-yaml</artifactId>
<version>0.3.0</version>
</dependency>
</dependencies>
Map<String, Object> map = new HashMap<>();
map.put("foo", "bar");
map.put("version", "1");
map.put("colors", Arrays.asList("red", "blue"));
String output = SimpleYamlOutput.toYaml(map);
Output:
foo: bar
version: 1
colors:
- red
- blue
Map<String, Object> map = new HashMap<>();
map.put("foo", "bar");
map.put("version", "1");
map.put("colors", Arrays.asList("red", "blue"));
SimpleYamlOutput yaml = SimpleYamlOutput.builder()
.numericFieldToQuote("version")
.flowStyleArrayField("colors")
.indentArrays(false)
.indentSize(3)
.quoteType(SimpleYamlOutput.QuoteType.SINGLE)
.build();
String output = yaml.dump(map);
Output:
foo: bar
version: '1'
colors: [ red, blue ]