【发布时间】:2015-12-12 10:00:32
【问题描述】:
private static final String URL = "http://www.livroandroid.com.br/livro/carros/carros_{tipo}.json";
public static List<Carro> getCarros(Context context, String tipo) throws IOException {
String url = URL.replace("{tipo}", tipo);
OkHttpClient okHttpClient = new OkHttpClient();
Request request = new Request.Builder()
.url(URL)
.build();
Response response = okHttpClient.newCall(request).execute();
String json = response.body().toString();
List<Carro> carros = parserJSON(context, json);
return carros;
}
如果我在调用getCarros 方法时打印出json 变量的值,我会在我的logcat 中看到以下消息:
com.squareup.okhttp.internal.http.RealResponseBody@1e11866
如何记录我收到的实际 JSON 字符串?
【问题讨论】: