Hello, how can we get response body from API using...
# android
h
Hello, how can we get response body from API using Coroutines without sorting? Gson sorts it. Thanks in advance.
😶 3
t
Using kotlinx.serialization, the order of serialization/deserialization is always the same as the order in your class declaration https://github.com/Kotlin/kotlinx.serialization/issues/121#issuecomment-665005796
c
gson sorts the response? that doesn't sound right. I've used gson for a long time and never noticed that.
h
@Colton Idle Yes, Gson sorts of a response body properties.
Copy code
val jsonString = Gson().toJson(it.value)     //  it:<Resource<LoginResponse>>
Log.d("LogFrag", "jsonString:\t $jsonString")
I get jsonString  with ascending order.