How does OkHttp get Json string?

后端 未结 5 1865
不知归路
不知归路 2020-12-02 08:50

Solution: It was a mistake on my side.

The right way is response.body().string() other than response.body.toString

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-02 09:52

    As I observed in my code. If once the value is fetched of body from Response, its become blank.

    String str = response.body().string();  // {response:[]}
    
    String str1  = response.body().string();  // BLANK
    

    So I believe after fetching once the value from body, it become empty.

    Suggestion : Store it in String, that can be used many time.

提交回复
热议问题