I'm using jackson in my java project
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>2.10.3</version>
</dependency>
I want to map this yaml to java classes
Settings:
- Setting: number1
Environments:
- Name: name
Value: 3
What I can think of now is this
public class MyYaml {
private Set<Setting> settings;
@JsonProperty("Settings")
public String getSettings() {
return settings;
}
public class Setting {
private String name;
private Environments environments;
@JsonProperty("??????????????????????")
public String getName() {
return name;
}
Now my question is how to map that attribute name for Setting class so that it returns name as the value
The field name.
A full example
usage example
with output
(Note: the lower case is only to avoid having to write down the rest of the fields, you can add them to be upper case)