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.
Answered by
JakeWharton
Jan 10, 2024
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.
0 replies
Answer selected by
olegaches
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to 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
@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