@GET("/api/v1/mydata")
suspend fun getMyData(
@Query("key1") key1: String? = null,
@Query("key2") key2: String? = "",
): Response<MyData>
Generated query
https://example.com/api/v1/mydata?key2=
@GET("/api/v1/mydata")
suspend fun getMyData(
@Query("key1") key1: Set<String> = emptySet(),
@Query("key2") key2: Set<String> = setOf("a", "b"),
): Response<MyData>
Generated query
https://example.com/api/v1/mydata?key2=a&key2=b
Corresponding property in data class annotated with @Serializable |
"foo" key is missing in JSON response | "foo":null in JSON response |
---|---|---|
val foo: List<String> | MissingFieldException | JsonDecodingException |
val foo: List<String>? | MissingFieldException | Success |
val foo: List<String> = emptyList() | Success | JsonDecodingException |
val foo: List<String>? = null | Success | Success |
Corresponding property in data class annotated with @Serializable |
"foo" key is missing in JSON response | "foo":null in JSON response |
---|---|---|
val foo: String | MissingFieldException | JsonDecodingException |
val foo: String? | MissingFieldException | Success |
val foo: String = "" | Success | JsonDecodingException |
val foo: String? = null | Success | Success |