Android org.json.JSONException:在改型中的字符0处输入结束

Android org.json.JSONException:在改型中的字符0处输入结束,android,json,retrofit,Android,Json,Retrofit,我已经创建了一个Android应用程序,并试图用数据库更新配置文件 if (response.isSuccessful()) { Log.d("TAG", "response: "+response.body().string()); String result = response.body().string(); JSONObject jsonObj = new JSONObject(result); if(jso

我已经创建了一个Android应用程序,并试图用数据库更新配置文件

 if (response.isSuccessful()) {
         Log.d("TAG", "response: "+response.body().string());

         String result = response.body().string();
         JSONObject jsonObj = new JSONObject(result);

         if(jsonObj.has("status")){

         if(jsonObj.get("status").equals("success")){

             Snackbar snackbar = Snackbar
             .make(layout, "User details successfully updated",
             Snackbar.LENGTH_LONG);

             snackbar.show();

     } else {
         Log.d("TAG","CLICK Failed");
         buttonVisible();
     }
当我试图
记录响应时,我得到
标记:响应:{“状态”:“成功”,“消息”:“用户详细信息已成功更新”。}
但是当我试图转换
response.body().string()时
string
我收到此错误
**org.json.JSONException:输入结束于**
的字符0处。你能告诉我怎么解决这个问题吗

试着把

String result = response.body().string();
以前

Log.d("TAG", "response: "+response.body().string());
看起来像

String result = response.body().string();
Log.d("TAG", "response: "+result);
以防有人碰到和我一样的怪事。我在开发过程中以调试模式运行代码,显然是从OKHTTP2.4开始的

..the response body is a one-shot value that may be consumed only once
因此,在调试时,有一个来自检查器的“幕后”调用,并且主体总是空的。请参阅:

尝试将

String result = response.body().string();
以前

Log.d("TAG", "response: "+response.body().string());
看起来像

String result = response.body().string();
Log.d("TAG", "response: "+result);
以防有人碰到和我一样的怪事。我在开发过程中以调试模式运行代码,显然是从OKHTTP2.4开始的

..the response body is a one-shot value that may be consumed only once

因此,在调试时,有一个来自检查器的“幕后”调用,并且主体总是空的。请参见:

日志中打印字符串对象,如下所示:

String result = response.body().string();
Log.d("TAG", "response: "+result);

Log
中打印字符串对象,如下所示:

String result = response.body().string();
Log.d("TAG", "response: "+result);

精心设计,完美回答,精心设计,完美回答。