val request:okhttp3.Request = okhttp3.Request.Builder().url(url).build()
val client = OkHttpClient()
client.newCall(request).enqueue(object : Callback {
override fun onResponse(call: Call, response: okhttp3.Response) {
val body = response?.body?.string()
println(body)
val jsonStr = XML.toJSONObject(body).toString()
println(jsonStr)
val gson = GsonBuilder().create()
val homeFeedSchools = gson.fromJson(jsonStr, HomeFeedSchools::class.java)
/*runOnUiThread {
recyclerView_SchoolList.adapter = SchoolsAdapter(homeFeedSchools)
}*/
}
override fun onFailure(call: Call, e: IOException) {
println("error")
}
})
}
}
data class HomeFeedSchools(
@SerializedName(“municipality”)
val municipality: Municipality? = null
)
data class Municipality(
@SerializedName(“name”)
val name: String? = null,
@SerializedName(“schools”)
val schools: Schools? = null,
@SerializedName(“xmlns:i”)
val xmlnsI: String? = null
)
data class Schools(
@SerializedName(“schoolInfo”)
var schoolInfo: List ===========> this is source of error
)
data class SchoolInfo(
@SerializedName(“id”)
val id: String? = null,
@SerializedName(“name”)
val name: String? = null,
@SerializedName(“schoolUrl”)
val schoolUrl: String? = null
)