2
我有一個類名字符串表示斯卡拉獲取類類型
val cls = Class.forName("clsName")
def fromJson[T: Manifest](me: String): T = {
Extraction.extract[T](net.liftweb.json.parse(me))
}
我想用它作爲T:清單即
JsonConverter.fromJson[cls.type](stringData)
這將返回一個錯誤
也試過
val t = Manifest.classType(cls)
JsonConverter.fromJson[t](stringData) // compile error
最好的辦法是什麼?有沒有辦法避免使用反射?
做了幾個更新 – cmbaxter 2013-05-07 10:50:41