title: Java Jackson writing object twice
body: <p>I have the following class which contains a String field and a Map field. I want to use Jackson to serialize it to json. </p>
  
  <pre><code>public class Mapping 
  
      private String mAttribute;
  
      @JsonIgnore
      private Map&lt;String, String&gt; mMap;
  
      @JsonAnyGetter
      public Map&lt;String, String&gt; getMap() {
          //some logic to populate map
      }
  
      @JsonAnySetter
      public void put(// some params) {
          //some more logic
      }
  
      @JsonProperty(value = "attribute")
      public String getAttribute() {
          return mAttribute;
      }
  
      public void setAttribute(String aAttribute) {
          mAttribute= aAttribute;
      }
  }
  </code></pre>
  
  <p>I instantiate a <code>Mapping</code> object and then use <code>ObjectMapper</code> to write it to a file.</p>
  
  <pre><code>ObjectMapper om = new ObjectMapper();
  om.writeValue(destFile, myMappingObject);
  </code></pre>
  
  <p>For some reason, it's writing the <code>Mapping</code> instance <code>myMappingObject</code> twice. I'm assuming I've not set some visibility option somewhere but I don't know where. </p>
  
  <p>The json looks like this, only it comes up twice in the file.</p>
  
  <pre><code>{
      "attribute" : "someValue",
      "map-key1" : "map-value1",
      "map-key2" : "map-value2"
  }
  </code></pre>
  
  <p>There's <a href="http://jira.codehaus.org/browse/JACKSON-384?page=com.atlassian.jira.plugin.system.issuetabpanels%3aall-tabpanel" rel="nofollow">this</a>, but apparently it was fixed in previous version of Jackson. I also tried changing the name of the method to <code>random()</code> and it still gets called twice (the number of times it should).</p>