I used Map<String, Object> data to make dynamic
@Configuration
@ConfigurationProperties("test")
@Data
public class Config {
private Map<String, Object> data;
}
How can I get data as expected?
example yaml
test:
a: a
b: b
c:
- name: name1
- name: name2
result
{
"a": "a",
"b": "b",
"c": {
0: {
"name": "name1"
},
1: {
"name": "name2"
}
}
}
expected
{
"a": "a",
"b": "b",
"c": [
{
"name": "name1"
},
{
"name": "name2"
}
]
}
This is because the data is store in a map. Add this data to a list and then print that list to get data in your requited format. Like this