1

I am new to Resteasy, I am calling a service and getting the response successfully. I am able to print the response as well (which is the expected response).
ClientResponse<String> response= clientRequest.post(String.class); System.out.println("response"+response.getEntity());

Console output is: response{"id":8,"displayName":"xyz_abc","roles":null, .....


But now I want to parse/map the response that I get from the service to a business object (like a User.java pojo) in client side application. I tried going through the docs but couldn't comprehend much. I tried googling, again not much help there. Please help me achieve this.

Thanks

Gadenkan
  • 1,691
  • 2
  • 17
  • 29

1 Answers1

2

Finally found the answer,

ClientResponse<String> response= clientRequest.post(String.class);
Gson gson = new Gson();
User user = gson.fromJson(response.getEntity(), User.class);

This solved my problem.

Gadenkan
  • 1,691
  • 2
  • 17
  • 29
  • I don't think you are supposed to use ClientRequest, that's for a "hand coded request". RESTEasy also allows you to declare an annotated interface where you can specify the details for each service and you can just use User as the return type. – sorin.silaghi Feb 11 '15 at 09:34