HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient client = new OkHttpClient.Builder()
.addInterceptor(interceptor)
.retryOnConnectionFailure(true)
.connectTimeout(15, TimeUnit.SECONDS)
.build();
Retrofit retrofit = new Retrofit.Builder().baseUrl(api_url).client(client).addConverterFactory(GsonConverterFactory.create()).build();
RetrofitService service = retrofit.create(RetrofitService.class);
Call<ApiGetMapFarms> getMapFarms = service.getMapFarms(api_token, farm_group_id);
getMapFarms.enqueue(new Callback<ApiGetMapFarms>() {
注:要是解析的化要一行一行的解析,要是一次性拷贝解析的化则会因为空格问题解析不成