I am am parsing a json. I would like to convert it's values to other types . i.e
//json = JSON String
val seq = net.liftweb.json.parse(json).\\("seq").values.toString.toLong
val userName = net.liftweb.json.parse(json).\\("name").values.toString
val intNum = net.liftweb.json.parse(json).\\("intId").values.toInt
I would like to cast it using generic method more "scala" way, I tried something like this:
object Converter{
def JSONCaster[T](json:String,s:String):T={
net.liftweb.json.parse(json).\\(s).values.toString.asInstanceOf[T]
}
}
but got casting error :
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Long at scala.runtime.BoxesRunTime.unboxToLong(Unknown Source)