I have a relatively simple object with a method that makes an HTTP request. The request automatically extracts the data according to class type and spits out the necessary object.
The problem is that I can't seem to reference the class dynamically. The code:
object abstractObject extends APIResource {
def retrieve(clazz: String, key: String) = {
request("GET", instanceURL(key)).extract[clazz]
}
}
clazz
defines a type that is to be passed on to extract
which allows the request to parse a JSON hash on-the-fly into an object. I need to somehow use that String to dynamically reference the class type and pass it to extract
.
Any ideas or will I need to re-architect this?