I am trying to map json dictionary of objects with known structure to POJO under jackson control:
import com.fasterxml.jackson.annotation.JsonProperty;
public class GetListOfRecordsResponse { @JsonProperty("recordsCount") private Integer recordsCount; // Works always
@JsonProperty("records") private Map<String, GeneratedRecordObject> records = new HashMap<>(); // Should also work without "records" (see second json)
}
It works properly for following (fake) json response:
{ "recordsCount": 2,
"records": { "-1": { ...
},
"1": { ...
}
}
How can I modify GetListOfRecordsResponse (JsonProperty attribute? Using another attribute?) to allow parsing following real world JSON response
{ "recordsCount": 2,
"-1": { ...
},
"1": { ...
}
}
Removing records does not work properly: the deserialized records is empty.
How can I solve this problem?