title: GSON: Missing fields when converting Java objects to JSON with gson.toJson
body: <p>I'm using the <a href="http://code.google.com/p/google-gson/" rel="nofollow">GSON 1.7.1</a> library to create a JSON representation of a number of Java objects. This works well, however when the class extends eg Vector&lt; String > then the fields are missing from the output.</p>
  
  <p><strong>Actual Output:</strong></p>
  
  <pre><code>[
    "String 1",
    "String 2"
  ]
  </code></pre>
  
  <p><strong>Required/Expected output:</strong>
  I would like both the contents of the new object's fields to be displayed as well as the contents of the Vector I'm extending. eg something like this...</p>
  
  <pre><code>{
    "extraInfo": "Extra Info",
    "vector": [
       "String 1",
       "String 2"
    ]
  }
  </code></pre>
  
  <p>I'm adding this to existing code so I don't have the option of changing the class structure from extending type Vector&lt; String > to containing a field of type Vector&lt; String ></p>
  
  <p><strong>Here's the example source code...</strong></p>
  
  <pre><code>import java.util.Vector;
  
  import com.google.gson.Gson;
  import com.google.gson.GsonBuilder;
  import com.google.gson.reflect.TypeToken;
  
  public class ExtendedStringVector extends Vector&lt;String&gt;{
  
      private String extraInfo = "";
  
      public String toString(){
          Gson gson = new GsonBuilder().setPrettyPrinting().create();
          String jsonOutput = gson.toJson(this);
          return jsonOutput;
      }
  
      public void setExtraInfo(String test) {
           this.extraInfo = test;
      }
  
      public String getExtraInfo() {
          return extraInfo;
      }
  
      public static void main(String[] args) {
          ExtendedStringVector esv = new ExtendedStringVector();
          esv.add("String 1");
          esv.add("String 2");
          esv.setExtraInfo("Extra Info");
          System.out.println(esv.toString());
      }
  }
  </code></pre>
  
  <p>There is some documentantion <a href="http://sites.google.com/site/gson/gson-user-guide#TOC-Serializing-and-Deserializing-Gener" rel="nofollow">here</a> which looks like it is close to what I need however it doesn't cover my case.</p>
  
  <p>Is there an easy way to get the output I expect? Have I missed a simple settings or type parameter?</p>