title: How do I convert Json object to a Java object dynamically
body: <p>Here is my use case:</p>
  
  <p>I have these classes on the serverside.</p>
  
  <pre><code>class Individual {
    protected String uri;
    protected int id;
  }
  
  class Person extends Individual {
    // Person properties like names, address etc
    String type = "Person";
  }
  
  class Role extends Individual {
    // Role properties like name, title etc
    String type = "Role";
  }
  
  class Organization extends Individual {
    // Org properties like name name, address etc
    String type = "Organization";
  }
  </code></pre>
  
  <p>I have a class say <code>Action</code> like below.</p>
  
  <pre><code>class Action {
    String performedBy; // This can be any Individual
  }
  </code></pre>
  
  <p>I have a controller that accepts an <code>Action</code>. I want the <code>Individual</code> to be correctly assigned depending on what the client sends. How should my <code>Action</code> &amp; other classes be defined to achieve this?</p>
  
  <p>if I send the following, I want <code>performedBy</code> to be a <code>Person</code>.</p>
  
  <pre><code>{
   "id": 10,
   "uri":"uri_blah",
   "lastname": "last_name",
   "type":"Person"
  }
  </code></pre>