Gson 转换报 com.google.gson.JsonIOException: JSON document was not fully consumed.

报错堆栈如下


转换之前对json串进行格式化即可解决

Gson gson = new GsonBuilder()
                   .setLenient()
                   .create();
           JSONObject jsonObject = new JSONObject(str);
           UserInfoBean bean = gson.fromJson(jsonObject.toString(4),UserInfoBean.class);

你可能感兴趣的:(Gson 转换报 com.google.gson.JsonIOException: JSON document was not fully consumed.)