I'm looking to parse a a result json who built like that :
{"list": [
{
"data1": "data1",
"transaction": {
"data2": "data2",
"data3": "data3"
},
"breakdowns": [
{
"data4": "data4",
"data5": "data5"
}
]
}
]}
I'm using moshi and okHttpClient to handle this json. I build the data class correclty
So now when I try to parse it (like that) :
200 -> {
val moshi = Moshi.Builder()
.add(KotlinJsonAdapterFactory())
.build()
val type: Type = Types.newParameterizedType(List::class.java,PaymentRequest::class.java)
try{
val q: JsonAdapter<List<PaymentRequest>> = moshi.adapter(type)
paymentRequest = q.fromJson(response.body!!.source())!!
}catch (e: Exception) {
println(e)
}
}
And I got this error : com.squareup.moshi.JsonDataException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at path $