0

I have a task in hand for which I have to make a rest call through Spring's restTemplate , parse the JSON data and insert it into the database.

To quote an simple example lets assume the JSON response something like this

{ "book_title": "Example book title", "book_price": "25 USD" }

For the database design I am considered to have two tables.

Book_Catalog (book_id, book_title)
Book_Pirce (book_id, book_price)

Thus for these two db tables I am creating two model objects (BookCatalog and BookPrice)

I am fetching the data with restTemplate like this

    ResponseEntity<BookCatalog> response = restTemplate.exchange(url, HttpMethod.GET, request, BookCatalog.class);

This way I get the response data only in one object, is there a way I can populate data in both the objects with Single rest call?

Tushar
  • 1,166
  • 4
  • 14
  • 31
  • take a look at the accepted answer ... maybe it is what you are looking for ... http://stackoverflow.com/questions/23674046/get-list-of-json-objects-with-spring-resttemplate/23675418#23675418 – kamokaze Jun 22 '15 at 20:17

1 Answers1

0

The only solution I can think of is getting response as string then converting it to desired pojo in code by a library jackson or something like that.

cool
  • 1,746
  • 1
  • 14
  • 15