我对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, *>>发布于 2018-03-08 19:30:59
这是在Klaxon 2.1.11中修正的。
https://stackoverflow.com/questions/49163896
复制相似问题