I've looked at similar questions but it doesn't seem to address my issue. I have a JSON payload that's returned from a Feign webservice call that I'm mapping to a POJO.
JSON
{
"fields":[
{
"field_one":"one value",
"field_two":"two value",
},
{
"field_one":"one value",
"field_two":"two value",
}
]
}
POJO - Wrapper Class
@Data
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class FieldsResponse {
public List<FieldInfo> fields;
}
POJO - Detail Class
@Data
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class FieldInfo{
@JsonProperty("field_one")
private String fieldOne;
@JsonProperty("field_two")
private String fieldTwo;
}
The POJO's are not being populated. If I change items in the wrapper POJO to a JsonArray everything works fine (i.e.: I can see the JSON response correctly). I've tried initializing the list in the wrapper object and have also experimented with using a vector instead.
Any ideas?
ETA: If I remove the @JsonPropery("field_one") mapping and rename the variable from fieldOne to field_one then it works. But this is not how I want it to work.