I'm frequently finding myself doing something like:
val json:Map[String,Any] = getJSON(...)
val v = json.get("username")
val uname = if ( v!=null ) v.asInstanceOf[toString] ) else null
whereas what I'd much prefer to write is:
val uname = json.get[String]("username")
but get doesn't take type parameters -- so my code is overly verbose as follows:
val uname = json.get("username").asInstanceOf[String]
How can I simplify access to containers in situations like this? (In the case of JSON-style objects I'm doing this a LOT)