title: How to serialize an object with jakcson and add dynamic field to it
body: <p>I have to following class:</p>
  
  <pre><code>public class CustomClass {
  
      @JsonProperty("Value")
      private boolean value;
      @JsonProperty("OtherObjects")
      private List&lt;OtherObjects&gt; objects;
      @JsonProperty("Num")
      private int num;
      @JsonIgnore
      public String dynamicParameterKey;
   }
  </code></pre>
  
  <p>On deserialization I get this object, as part of nested objects that each has it rules of deserialization and serializations.
  however on serialization I need this object to add another field with "dynamicParamterKey" as it's key and "value" as it's value </p>
  
  <p>I can't add a field in compile time as the key is dynamic.</p>
  
  <p>So what I need to do is to serialize the object as regular and add this custom field.</p>
  
  <p>This class is a part of a whole bunch of classes so I need it to be encapsulated as much as possible (not using a custom deserializer and add it to the ObjectMapper), and I can use treeMap or something because it is a part of a larger json that is sent to me.</p>
  
  <p>How can I acheive this?   </p>