-
BackgroundI have a some object, for example: data class Person(val name: String) And some API that returns an array of these Person: [{"name": "John"}, {"name": "Alex"}] QuestionWhen I use the pure ktor api I can use this API like this: val response = client.get("https://persons.example/getAll").body<List<Person>>()
println(response) Result: When i use retrofit i can use this API like this: interface PersonApi {
@GET("getAll")
suspend fun getPersons(): List<Person>
}
val response = personApi.getPersons()
println(response) Result: BUT
How I can get a JSON list/array using Ktorfit? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Hi, it should work that way. Are you setting the right baseUrl? Are you getting a response with:
|
Beta Was this translation helpful? Give feedback.
-
Thank you for the example project, i can reproduce the issue, it |
Beta Was this translation helpful? Give feedback.
-
Ktorfit 1.4.1 is now released |
Beta Was this translation helpful? Give feedback.
Thank you for the example project, i can reproduce the issue, it
s a bug. A workaround is to wrap it in a Response
Response<Array>. I
m planning to fix the bug today