okhttp请求返回值只有一个数值

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_35506618/article/details/85247566

返回值如上图所示,

body里都是为空,code=200,就是拿不到值正确姿势如下:response.body().string()

  final Request request = new Request.Builder()
                .url(url)
                .build();
        Call call = okHttpClient.newCall(request);
        call.enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {
                e.printStackTrace();
            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                int anInt = Integer.parseInt(response.body().string());
                System.out.println("我是异步线程,线程Id为:" + anInt);
            }
        });

猜你喜欢

转载自blog.csdn.net/qq_35506618/article/details/85247566