I have class that looks like this:
public class Data {
@JsonProperty(\"difficulties\")
private U[] data;
// ... geter setter construct
You can use @JsonAnyGetter annotation.
public class Data {
@JsonIgnore
private U[] data;
@JsonIgnore
private String propertyName;
public Data(String propertyName) {
this.propertyName = propertyName;
}
// ... geter setter
@JsonAnyGetter
public Map any() {
return Collections.singletonMap(propertyName, data);
}
}
And use it like below:
Data difficulties = new Data<>("difficulties");
write whatever you want instead of "difficulties" string. Set your list to Data generic class instead of Difficulties object if you want