I keep getting this Error call
Yet I'm not sure where to look to fix it. I have a raw JSON file in my Res Folder under the directory "Raw"
The Error is coming at my Repository
class C51Repository {
private val moshi = Moshi.Builder().add(KotlinJsonAdapterFactory()).build()
suspend fun getAllOffers(context: Context): List<Offer> {
delay(2_000)
val json = context.resources.openRawResource(R.raw.c51).bufferedReader().use {
it.readText()
}
val offerList = moshi.adapter(C51::class.java).fromJson(json) //<- RIGHT HERE
return offerList!!.networkOffers.map {
Offer(
cash_back = it.cash_back,
image_url = it.image_url,
name = it.name,
offer_id = it.offer_id
)
}
}
}
Any Help is appreciated, Thanks.
P.S. I read that it could be a Moshi bug, but I don't know how to go about fixing the bug.
It was the naming of the variables. I had name some variables different than the one called in the raw files. MAKE SURE YOU GET THOSE VARIABLE NAMES CORRECTLY