I've REST API which exposes the JSON with a link to the next page and data as shown below:
{
"nextPageLink" : "rest_api_url_to_next_page"
"myData" : [ {
"key" : {
"d1" : "d1_value",
"d2" : "d2_value"
},
"productData" : {
"d3" : "d3_value",
"d4" : "d4_value"
}
"d5" : "d5_value",
"d6" : "d6_value"
}
There are around 1000s of pages with nextPageLink. On the last page, its empty. Can you please guide me how to design this in java. Also, I've such 10 more different REST APIs to handle.
My approach:
- Create 2 pojos, one for key (keyPojo) and another for rest of the data(restDataPojo). Create a map with key as keyPojo and value as restDataPojo.
- Create a pojo which has all the values, and dump data in the list of type pojo.
Is there any better approach to store such data? is this approach efficient enough?