Retrofit ignores a moshi JsonAdapter #4032
Retrofit ignores a moshi JsonAdapter, it's not calling toJson() for the query param |
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 |
0 replies
Answer selected by
oleginvoke
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
@Querydocs) 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