title: Convert Java POJO to Map without JSON serialization
body: <p>I'd like to convert a Java POJO into a Map <em>without</em> using JSON serialization for the properties (e.g. that Date's are converted to a long or a ISO8601 String). I just want the fields to be retained as they are.</p>
  
  <p>For example if I have a POJO defined like this:</p>
  
  <pre><code>public class MyPojo {
      private Date date;
      private String x;
  
      public MyPojo(Date date, String x) {
          this.date = date;
          this.x = x;
      }
  
      public Date getDate() {
          return date;
      }
  
      public void setDate(Date date) {
          this.date = date;
      }
  
      public String getX() {
          return x;
      }
  
      public void setX(String x) {
          this.x = x;
      }
  }
  </code></pre>
  
  <p>I know I can use <a href="https://github.com/FasterXML/jackson" rel="nofollow noreferrer">Jackson</a> as described in <a href="https://stackoverflow.com/questions/39543926/how-to-convert-pojo-to-map-and-vice-versa-in-java">this</a> Stackoverflow question but the result is not what I want. For example if I do:</p>
  
  <pre><code>Map&lt;String, Object&gt; x = new ObjectMapper().convertValue(new MyPojo(new Date(), "x"), new TypeReference&lt;Map&lt;String, Object&gt;&gt;() {});
  System.out.println(x);
  </code></pre>
  
  <p>I get this result:</p>
  
  <pre><code>{date=1528521584984, x=x}
  </code></pre>
  
  <p>whereas I would simply like a Map retaining the <code>java.util.Date</code> instance without being serialized. </p>
  
  <p>Note that I obviously would like this work for nested Pojo's such as:</p>
  
  <pre><code>public class MyPojo {
     private MyOtherPojo otherPojo;
     ...
  }
  </code></pre>
  
  <p>How can I achieve this?</p>