Skip to content

Retrofit ignores a moshi JsonAdapter #4032

Closed Answered by JakeWharton
olegaches asked this question in Q&A
Discussion options

You must be logged in to vote

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 calls toString().

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

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by olegaches
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants
Converted from issue

This discussion was converted from issue #4031 on January 10, 2024 17:54.