title: Gson Serializing the Integer object
body: <p>I'm generating JSON using the Gson library. I'm attempting to generate JSON like:</p>
  
  <pre><code>{"Plaintext":{"type":"List","value":["1","2","3","4"]},"SINGLE_FUNCTION":{"value":"1"},"IN_FLOW":{"value":10}}
  </code></pre>
  
  <p>However, the JSON that is appearing is..</p>
  
  <pre><code>{"Plaintext":{"type":"List","value":["1","2","3","4"]},"SINGLE_FUNCTION":{"value":"1"},"IN_FLOW":{"value":{"value":10}}}
  </code></pre>
  
  <p>The problem, I found is that when my objects are being created, an <code>Integer</code> object is being stored. This is because of the type of the mapping is <code>Object</code>, which means the <code>int</code> type that I'm storing is automatically wrapped to type <code>Integer</code> and Gson is rendering the only non-null value, <code>value</code> inside the <code>Integer</code> class.</p>
  
  <p>My question is, is there a way of having Gson render an <code>Integer</code> object as if it were a primitive type <code>int</code>?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>So, The whole <code>JSON</code> is a <code>Map</code>. This Map is defined as:</p>
  
  <pre><code>private Map&lt;String, ParameterWrapper&gt; parameterMap;
  </code></pre>
  
  <p>The class <code>ParameterWrapper</code> looks like this:</p>
  
  <pre><code>public class ParameterWrapper&lt;T&gt; {
  
      private String type;
  
      private T value;
  
      public ParameterWrapper(String type, T value) {
          this.type = type;
          this.value = value;
      }
  
      public String getType() {
          return type;
      }
  
      public void setType(String type) {
          this.type = type;
      }
  
      public T getValue() {
          return value;
      }
  
      public void setValue(T value) {
          this.value = value;
      }
  }
  </code></pre>
  
  <p>I suspect that because I'm not specifying a type <code>T</code> for <code>ParameterWrapper</code>, it's defaulting to <code>Object</code>, which is why Gson is outputting it as an <code>Object</code> and not an <code>int</code>, despite it being an instance of <code>Integer</code>.</p>