I have the following response.
{
"data": "[{\"{Test}.id\":12984,\"{Test}.url\":\"https://login.test.com/0010b00002CIwX5AAL\"},{\"{Test}.id\":84592,\"{Test}.url\":\"\"}]"
}
I tried to solve it via JSON to Java object deserialization with escaped properties but it looks like I did something wrong or didn't understand properly how to use this approach because I got an empty list in data object.
public class Wrapper {
@JsonProperty("data")
@JsonDeserialize(using = ProviderResponseDeserializer.class)
private List<TestObject> data;
}
public class TestObject{
@JsonProperty("{Test}.id")
public Integer id;
@JsonProperty("{Test}.url")
public String url;
}
public class ProviderResponseDeserializer extends JsonDeserializer<List<TestObject>> {
private static final ObjectMapper mapper = new ObjectMapper();
@Override
public List<TestObject> deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
return mapper.readValue(jsonParser.getText(), mapper.getTypeFactory().constructCollectionType(List.class, TestObject.class));
}
}
Could you help me with what I did wrong or suggest some other approach?