Here's a sample of the data I get from my REST endpoint:
{
"0":{
"id":"1",
"name":"List #1"
},
"1":{
"id":"2",
"name":"Some other list"
},
"2":{
"id":"3",
"name":"A third object"
},
"3":{
"id":"6",
"name":"You get the idea"
},
"result_code":1,
"result_message":"Success: Something is returned",
"result_output":"json"
}
I'm struggling to map this to an Object in Java.
The stupid way of doing this that works is like this:
public class MyLists
{
@JsonProperty("0")
ActiveCampaignList list0;
@JsonProperty("1")
ActiveCampaignList list1;
@JsonProperty("2")
ActiveCampaignList list2;
@JsonProperty("3")
ActiveCampaignList list3;
// plus an arbitrary number of additional list# variables
// getters and setters
}
There must be a better way of mapping the returned JSON to a Java object right?
Note that I'm using rt.postForEntity()
to get JSON from the RESTful endpoint