Mam modernizacyjny skonfigurować z HttpLoggingInterceptor
tak:Jak ładnie wydrukować w Retroficie 2?
Gson gson = new GsonBuilder()
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
.setPrettyPrinting() // Pretty print
.create();
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient client = new OkHttpClient.Builder()
.addInterceptor(interceptor)
.build();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create(gson))
.client(client)
.build();
Na moim przykład Gson, zrobiłem setPrettyPrinting
a ja wciąż kompaktowe wyjścia JSON. Oto moje biblioteki.
compile 'com.google.code.gson:gson:2.5'
compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'
compile 'com.squareup.okhttp3:logging-interceptor:3.0.1'
compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
compile 'com.squareup.okhttp3:okhttp:3.0.1'
Jak mogę uzyskać ładne drukowanie za pomocą Retrofit 2? Dzięki.
EDIT: Aktualizacja moich bibliotek i nadal nie działa
Próbowałem z najnowszymi beta4 i nadal nie działa. – Schinizer