title: Cast to class from JSONObject
body: <p>I got JSONObject from service response.</p>
  
  <p>Well in case of an error I need to cast it to one of the error classes.</p>
  
  <p>Json is something like</p>
  
  <pre><code>{"message":"This means that the userID is not valid.","name":"UserNotFoundException"}
  </code></pre>
  
  <p>where name can be any of the exceptions in model package</p>
  
  <p>Can I do this?</p>
  
  <pre><code>Class ex = Class.forName("com.myapp.model.Exceptions." + jsonObject.getString("name"));
  </code></pre>
  
  <p>How can I cast ex to UserNotFoundException class so I can use its methods i.e.
  ex.doSomething()</p>