Chetna
Chetna

Reputation: 864

Unable to parse JSON using Retrofit

I am using Retrofit to hit an api. I need to get both Json and header response. So my interface method is like this. So in Response type Object I get response header from response.getHeaders(). But when I try to get the json response from response.getBody(), I don't get a proper response. I need help in fetching and parsing the json response from the Response object :-(

@GET("/api/hello/categories")
retrofit.client.Response getData();

Upvotes: 2

Views: 1521

Answers (1)

f2prateek
f2prateek

Reputation: 2084

getBody() doesn't return a String directly, you'll have to convert it yourself if you don't want to user Retrofit's built converters.

This link should be a simple way to grab the String from the response, and you can parse it accordingly.

Upvotes: 1

Related Questions