我的JSON看起来像这样
{"status":true,"error_message":[],"locations":[{"id":"12","name":"office"},{"id":"13","name":"home"}]}我正在使用协同和改造来与web服务进行通信。我想得到office和home在locations arrayList,但我只能得到office。
fun getLocation(): String {
val service = RetrofitFactory.makeRetrofitService()
GlobalScope.launch(Dispatchers.Main) {
val request = WebApi.getLocationList(context)
request?.locations.let {
for (i in it!!.iterator()) {
longToast(request?.locations!!.size.toString())
longToast(request?.locations!!.component1().name.toString())
}
}
}
return "sss"
}输出
2
office
2
office期望输出
2
offine
2
home发布于 2019-01-30 08:24:09
吐司不使用for循环中的i。尝试切换到这个:longToast(i.component1().name.toString())
https://stackoverflow.com/questions/54436011
复制相似问题