私は私の改造は、このようなHttpLoggingInterceptor
に設定している:私のGsonインスタンス上Retrofit 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();
、私はsetPrettyPrinting
を行なったし、私はまだコンパクトなJSONの出力を取得します。 ここに私の図書館があります。
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'
Retrofit 2を使用してきれいな印刷を達成するにはどうすればよいですか?おかげさまで
EDITは:私のライブラリを更新し、まだ
は、最新beta4にしようと、それはまだ動作しませんでした。 – Schinizer