lundi 7 septembre 2020

Looping rest api

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-api 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.

Is there any better approach to store such data? is this approach efficient enough?

Aucun commentaire:

Enregistrer un commentaire