hunachi’s diary

Android studio でお勉強してます。

gson,retrofitで@Path

gson,retrofitで@Path(だけなのかはわからないけど,)使うとデフォルトでhoge="hoge"のようにダブルクォーテーションがつくので、

e.g.

hoge=hoge

という風に送りたいのに

hoge="hoge"

になるといった症状です(@Partの副作用?:;(∩´﹏`∩);:?)

stackoverflow.com

これのSolution2をしましょう。

retrofit = Retrofit.Builder()
.baseUrl("")
.addConverterFactory(StringConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create(gson))
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build()

「StringConverterFactoryはGsonConverterFactoryの前に入れる!!」って注意書きが書いてあるのでそれは守りましょうね。