I am wondering if it is possible to instantiate an object
(companion object) dynamically using Manifest
. I want to parse json in MongoRecord but to do so, I have to understand which is the type that is passed.
def getCompanion[T](implicit mf : Manifest[T])={
if (mf <:< classOf[MongoRecord[C]]){
Class[C].asInstanceOf[MongoRecord].setFieldsFromJSON(request.body.toString)
}
}
but I am receiving an error during compilation:
error: object Class is not a value Class[C].asInstanceOf[MongoRecord].setFieldsFromJSON(request.body.toString)
it is a difficult topic to me. Perhaps it is not feasible but I would like to know if it is possible? Thanks