title: Java convert to a list of objects from JSON
body: <p>I am using Java 7.  I also use <code>com.fasterxml.jackson.databind.objectmapper</code> to convert json to a Java object.</p>
  <p>When I initially convert the the Java object to JSON, I do the following:</p>
  <pre><code>List&lt;QuoteDTO&gt; selectedQuoteDTOs = ...
  String jsonSelectedQuoteDTOs = mapper.writeValueAsString(selectedQuoteDTOs);
  </code></pre>
  <p>When I convert the JSON back to a JAVA object I do the following:</p>
  <pre><code>List&lt;QuoteDTO&gt; selectedQuoteDTOs = mapper.readValue(jsonSelectedQuoteDTOs, List.class);
  </code></pre>
  <p>However the <code>selectedQuoteDTOs</code> are not of type <code>QuoteDTO</code>, but of rather of <code>LinkedHashMap</code>.</p>
  <p>Resulting in me getting the following error:</p>
  <blockquote>
  <p>java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast
  to com.abc.model.QuoteDTO</p>
  </blockquote>
  <p>when I do this:</p>
  <pre><code>for (QuoteDTO selectedQuoteDTO : selectedQuoteDTOs) {
  </code></pre>
  <p><strong>Question</strong></p>
  <p>When converting the JSON to JAVA, how do I convert the object to a <code>List&lt;QuoteDTO&gt;</code>, instead of a <code>List&lt;LinkedHashMap&gt;</code>?</p>
  <p>The <code>LinkedHashMap</code> keys are the name of the <code>QuoteDTO</code> member variables.</p>