title: Jackson - Modify an attribute at runtime without annotation
body: <p>Let's say I have a bean:</p>
  
  <pre><code>public class Msg {
    private int code;
    private Object data;
  
     ... Getter/setters...
  }
  </code></pre>
  
  <p>And I convert it into JSON or XML with this kind of test code:</p>
  
  <pre><code>public String convert() {
    Msg msg = new Msg();
    msg.setCode( 42 );
    msg.setData( "Are you suggesting coconuts migrate?" );
  
    ObjectMapper mapper = new ObjectMapper();
    return mapper.writeValueAsString( msg );
  }
  </code></pre>
  
  <p>The output will be somehow like that :</p>
  
  <pre><code>{"code":42,"data":"Are you suggesting coconuts migrate?"}
  </code></pre>
  
  <p>Now let's say I want to replace the 'data' attribute with some dynamic name:</p>
  
  <pre><code>public String convert(String name) {
    Msg msg = new Msg();
    msg.setCode( 42 );
    msg.setData( "Are you suggesting coconuts migrate?" );
  
    ObjectMapper mapper = new ObjectMapper();
    // ...DO SOMETHING WITH MAPPER ...
    return mapper.writeValueAsString( msg );
  }
  </code></pre>
  
  <p>If I call the function <strong>convert( "toto")</strong> I woukld like to have this output:</p>
  
  <pre><code>{"code":42,"toto":"Are you suggesting coconuts migrate?"}
  </code></pre>
  
  <p>If I call the function <strong>convert( "groovy")</strong> I woukld like to have this output:</p>
  
  <pre><code>{"code":42,"groovy":"Are you suggesting coconuts migrate?"}
  </code></pre>
  
  <p>Of course I could do a String replace after JSON creation, but if you have an answer with a programmatic approach I'll take it.</p>
  
  <p>Thanks</p>