title: How can I unmarshalling nested Object from a String format with JSON Jersey
body: <p>I know there are similar questions but any of them are usefull for me (or seem to be).</p>
  
  <p>I need to execute following statements:</p>
  
  <pre><code>ClassA a = new ClassA(); 
  String JSON_str = objectMapper.writeValueAsString(a);
  
  ClassA a1 = (ClassA)objectMapper.readValue(JSON_str, ClassA.class);
  ClassB b = (ClassB)a1.getAttribute1();
  </code></pre>
  
  <p>If i do the code above i receive following error:</p>
  
  <p>"<strong>java.util.LinkedHashMap cannot be cast to ClassB</strong>"</p>
  
  <p>The method getAttribute1 returns the ClassA attribute1 defined as "Object attribute1".
  It will be initialized with an object of class B at runtime.</p>
  
  <p>Please help me ^^.</p>
  
  <p>Thank you in advance.
    Leonardo</p>