Dimple patel
Dimple patel

Reputation: 152

Retrofit Response in Android

What is the difference betweeen string() and toString() for Retrofit Response ?

Can any tell the difference in details.

 response.body().string();

 response.body().toString();

Upvotes: 1

Views: 392

Answers (3)

artemiygreg
artemiygreg

Reputation: 101

response.body().toString(); - Convert object responseBody(body()) to string

return getClass().getName() + "@" + Integer.toHexString(hashCode());

response.body().string(); - Convert response from server to string;

Upvotes: 0

Sandeep Sankla
Sandeep Sankla

Reputation: 1260

.toString(): This returns your object in string format.

.string(): This returns your response.

Upvotes: 0

Anton Potapov
Anton Potapov

Reputation: 1275

response.body().string(); returns response body converted to String. JSON, for example.

response.body().toString(); returns string look of ResponseBody object. It hash, class ...

Upvotes: 4

Related Questions