We have JSON generated by Spring. This is Spring Data Page

{ "content" : [ { "id" : 1, "create_date" : "2016.01.12 12:24:06", "last_modified_date" : null, "prop" : [ ] }, { "id" : 2, "create_date" : "2016.01.12 12:24:28", "last_modified_date" : null, "prop" : [ ] }, { "id" : 3, "create_date" : "2016.01.12 12:24:29", "last_modified_date" : null, "prop" : [ ] } ], "last" : true, "total_pages" : 1, "total_elements" : 3, "size" : 50, "number" : 0, "sort" : null, "first" : true, "number_of_elements" : 3 } 

We see here three unpretentious objects on one page. Question: How can I take Page T> from this Jason using the Spring Rest Template (preferably)?

  • Do you get such JSON in response? If yes - you can try through restTemplate.exchange, indicating in the type of response a prepared class that describes the structure of the answer. As a result, get ResponseEntity <Your_class>. Why exactly Page? - Chubatiy
  • This is the standard class of the spring, has methods getTotal (), getSize, getLast () and so on. So far, we stupidly rewrote this class, added manually what we need and use. But I would not like the crutch method =) - Snowy

0