I'm trying to convert mutablelist to jsonarray to be able to send it to next activity since it seems to be impossibe to just pass the damn mutablelist without adding any serialization plugin
This is what I have so far:
val arrr: Array<JSONObject> = arrayOf()
var curr = 0
for(jsonIndex in 0 until memes.size - 1) {
val rootObject = JSONObject()
rootObject.put("nickname", memes[jsonIndex].nickname)
rootObject.put("title",memes[jsonIndex].title)
arrr[curr] = rootObject
curr++
}
I get the error:
ArrayIndexOutOfBoundsException: length=0; index=0
referred to the line
arrr[curr] = rootObject
Whats's wrong here?
arrrarray is an array of length zero because you instantiated it with nothing to put in it.