private static final String URL = "http://www.livroandroid.com.br/livro/carros/carros_{tipo}.json";
public static List 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 carros = parserJSON(context, json);
return carros;
}
如果我在调用getCarros方法时打印出json变量的值,我在logcat中看到以下消息:
com.squareup.okhttp.internal.http.RealResponseBody@1e11866
如何记录我收到的实际JSON字符串?