Gson解析多元數組
1、多元數組:
// 三維數組的字元串:
{
"dept": "[[[120.835572525992,31.287890782283995],[120.83580901430696,31.290597379359326]]]"
}
2、Gson解析(TypeToken):
val jsonArrayStr = "[[[120.835572525992,31.287890782283995],[120.83580901430696,31.290597379359326]]]"
val gson = Gson()
val type = object : TypeToken<MutableList<MutableList<MutableList<Double>>>>() {}.type
val resultList: MutableList<MutableList<MutableList<Double>>> = gson.fromJson(jsonArrayStr , type)
// val jsonArray: JsonArray = JsonParser().parse(jsonArrayStr).asJsonArray
// val resultList: MutableList<MutableList<MutableList<Double>>> = gson.fromJson(jsonArray , type)