title: JSON and object inheritance
body: <p>We are trying to move from SOAP to REST and we stumbled across this issue
  Here party can be of type Individual or Organization. </p>
  
  <p>Sample XMLs</p>
  
  <pre><code>&lt;customer&gt;
    &lt;details&gt;
      &lt;party xsi:type="Individual"&gt;
        &lt;externalID&gt;ABC123&lt;/externalID&gt;
        &lt;firstname&gt;John&lt;/firstname&gt;
        &lt;lastname&gt;Smith&lt;/lastname&gt;
      &lt;/party&gt;
    &lt;/details&gt;
  &lt;/customer&gt;
  
  &lt;customer&gt;
    &lt;details&gt;
      &lt;party xsi:type="Organization"&gt;
        &lt;externalID&gt;APPLE&lt;/externalID&gt;
        &lt;organizationName&gt;Apple Inc&lt;/organizationName&gt;
        &lt;listingName&gt;APPLE&lt;/listingName&gt;
      &lt;/party&gt;
    &lt;/details&gt;
  &lt;/customer&gt;
  </code></pre>
  
  <p>However when we move to JSON representation of the same, we encounter the problem where the inheritance information is lost</p>
  
  <p>JSON Sample</p>
  
  <pre><code>{
    "customer": {
      "details": {
        "party": {
          "externalID": "ABC123",
          "firstname": "John",
          "lastname": "Smith"
        }
      }
    }
  }
  
  {
    "customer": {
      "details": {
        "party": {
          "externalID": "APPLE",
          "organizationName": "Apple Inc",
          "listingName": "APPLE"
        }
      }
    }
  }
  </code></pre>
  
  <p>So when we convert the JSON back to Java object using libraries like Gson, we loose the definition of Individual or Organization. </p>
  
  <p>While one of the workaround is to build additional services to retrieve the "details" returning the concrete types (Individual or Organization), 
  is there any other approach to handle this in JSON?</p>