I was trying to parse Json in array in array But It doesn't worked. Source was like this
@POST("/storyGet")
fun getStory() : Call<ArrayList<StoryData>>
this is API.kt's and
Client.retrofitService.getStory().enqueue(object :
retrofit2.Callback<ArrayList<StoryData>> {
override fun onResponse(call: Call<ArrayList<StoryData>>?, response: Response<ArrayList<StoryData>>?) {
val repo = response!!.body()
when (response.code()) {
200 -> {
repo!!.indices.forEach {
items += StoryDataSubListItem(
repo[it][it][it].alreadyWatch,
repo[it][it][it].createdAt,
repo[it][it][it].imgUrl,
repo[it][it][it].storyUUID,
repo[it][it][it].userName,
repo[it][it][it].userName,
repo[it][it][it].userUUID
)
recyclerView!!.adapter?.notifyDataSetChanged()
}
}
}
}
override fun onFailure(call: Call<ArrayList<StoryData>>?, t: Throwable?) {
}
})
This is my Retrofit Data and
class StoryData : ArrayList<StoryDataSubList>()
this is first Array and
class StoryDataSubList : ArrayList<StoryDataSubListItem>()
this is my second array and
data class StoryDataSubListItem(
val alreadyWatch: List<Any>,
val createdAt: String,
val imgUrl: String,
val storyUUID: String,
val userName: String,
val userProfileImgUrl: String,
val userUUID: String)
this is dataclass and json in array in array's format is
[
[
{
"alreadyWatch": [],
"createdAt": "test",
"_id": "_id",
"userUUID": "userUUID2",
"userName": "userName2",
"userProfileImgUrl": "false",
"imgUrl": "imageUrl",
"storyUUID": "StoryUUID",
"__v": 0
}
],
[
{
"alreadyWatch": [],
"createdAt": "test",
"_id": "_id",
"userUUID": "userUUID",
"userName": "TEST NAME",
"userProfileImgUrl": "false",
"imgUrl": "imageURL",
"storyUUID": "StoryUUID",
"__v": 0
}
]]
When I saw logcat, server was in normal operation when like this how should I fix It? please help and thank you in advance.