title: Gson serialize null for specific class or field
body: <p>I want to serialize nulls for a specific field or class.</p>
  
  <p>In GSON, the option <code>serializeNulls()</code> applies to the whole JSON.</p>
  
  <p>Example:</p>
  
  <pre><code>class MainClass {
      public String id;
      public String name;
      public Test test;
  }
  
  class Test {
      public String name;
      public String value;    
  } 
  
  MainClass mainClass = new MainClass();
  mainClass.id = "101"
  // mainClass has no name.
  Test test = new Test();
  test.name = "testName";
  test.value = null;
  mainClass.test = test;    
  </code></pre>
  
  <p>Creating JSON using GSON:</p>
  
  <pre><code>GsonBuilder builder = new GsonBuilder().serializeNulls();
  Gson gson = builder.create();
  System.out.println(gson.toJson(mainClass));
  </code></pre>
  
  <p>Current ouput:</p>
  
  <pre><code>{
      "id": "101",
      "name": null,
      "test": {
          "name": "testName",
          "value": null
      }
  }
  </code></pre>
  
  <p>Desired output:</p>
  
  <pre><code>{
      "id": "101",
      "test": {
          "name": "testName",
          "value": null
      }
  }
  </code></pre>
  
  <p>How to achieve the desired output?</p>
  
  <p>Preferred solution would have the following properties:</p>
  
  <ul>
  <li>Do <em>NOT</em> serialize nulls by default,</li>
  <li>Serialize nulls for fields with a specific annotation.</li>
  </ul>