Kotlin Json解析器

我在Kotlin有这个JSON,我不能获取和解析。 任何快速的帮助。 请。

[{platform: {name: "mena-web",publishingRegion: "mena",platformGroup:"web",id: 2,countryCode: "AE",locales: {locale:["en_US","ar_AE"]}}}] 

这里是我的数据类:

 data class Locales(var locale: ArrayList<String>) {} data class Platform(var name: String, var publishingRegion: String, var platformGroup: String, var id: Int, var countryCode: String, var locales: Locales) {} data class Json(var platform: Platform) {} 

这是我的JSON API接口:

 interface Api { @GET("/me.json2") fun getGeo(callback: Callback<List<Json>>): Call<List<Json>> } 

这是我的RestAPI:

 class RestAPI(val api: Api) { fun getNews(callback: Callback<List<Json>>) { val call = api.getGeo(callback) call.enqueue(callback) } } 

这是我的RestAPI调用:

 try { val api: RestAPI val retrofit = Retrofit.Builder() .baseUrl(PLATEFORM_URL) .addConverterFactory(MoshiConverterFactory.create()) .build() api = retrofit.create(RestApi::class.java) val callback = object : Callback<List<Json>> { override fun onResponse(call: Call<List<Json>>?, response: retrofit2.Response<List<Json>>?) { response?.isSuccessful.let { this@MainActivity.photos = response?.body() } } override fun onFailure(call: Call<List<Json>>?, t: Throwable?) { Log.e("MainActivity", "Problems calling API", t) } } api.getGeo(callback) // Log.e("Message", test.getNews().toList().toString()) } catch(e:Exception){ Log.e("Message", e.message) } 

多谢你们! 我找到了答案,更改解析器后,所有的stat工作

MoshiConverterFactory到GsonConverterFactory。