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)