我有以下代码,用于使用Jerkson(Jackson 的 Scala 包装器)解析以下 JSON 字符串:
代码:val vertex = Json.parse[Ranked[UserVertex]](rawString)
杰森:"originalPos":"515693049","rankScore":1.2409032357406248E8,"ranked":{"userId":"101010110","userName":"John","channel":"thirtyfive"}}
下面的 JSON 由这个 Scala 类表示:
case class Ranked[T] (
val originalPos: String,
val rankScore: Double,
val ranked: T
)
T 是一个UserVertex
类,上面有以下字段(userId、userName、channel)。当我尝试解析 JSON 字符串时,出现以下错误:
[error] application - Could not parse the string:
{"originalPos":"655330261","rankScore":1.2423105672295567E8,"ranked":{"userId":"655330261","userName":"Sheile Mercado-Mallari","channel":"facebook"}}
java.lang.ClassNotFoundException: T
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at com.codahale.jerkson.util.CaseClassSigParser$.loadClass(CaseClassSigParser.scala:153)
看起来 ClassLoader 找不到该类,但它肯定已加载。知道这是什么根本原因吗?我这里有某种多类加载器问题吗?谢谢!