【发布时间】:2018-03-08 01:20:10
【问题描述】:
我是 Kotlin 的新手,正在尝试解析 JSON 中的列表:
data class Root (val lists: List<List<String>>)
val result = Klaxon().parse<Root>("""
{
"lists": [["red", "green", "blue"]]
}
""")
但是我得到了这个运行时异常:
Exception in thread "main" java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class
Klaxon 好像不太明白List<List<String>>。
我也需要这个一般用于嵌套集合:
List<List<*>>Map<String, List<*>>List<Map<String, *>>Map<String, Map<String, *>>
【问题讨论】:
-
这已在 Klaxon 2.1.11 中修复。