Retrofit ignores a moshi JsonAdapter #4032
-
Retrofit ignores a moshi JsonAdapter, it's not calling toJson() for the query param |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Query parameter stringification does not go through the body converters since those can produce non-string content (e.g., protobuf). Instead, it uses a string converter (documented on the If you want to serialize query parameters to JSON using a JSON library, I have written up a sample which does this here: https://github.com/square/retrofit/blob/master/samples/src/main/java/com/example/retrofit/JsonQueryParameters.java |
Beta Was this translation helpful? Give feedback.
Query parameter stringification does not go through the body converters since those can produce non-string content (e.g., protobuf). Instead, it uses a string converter (documented on the
@Query
docs) to render the value as a string. By default the only one registered is one which callstoString()
.If you want to serialize query parameters to JSON using a JSON library, I have written up a sample which does this here: https://github.com/square/retrofit/blob/master/samples/src/main/java/com/example/retrofit/JsonQueryParameters.java