title: Gson serialize POJO with root value included?
body: <p>I'm having a problem serializing an object using Gson.</p>
  
  <pre><code>@XmlRootElement
  class Foo implements Serializable {
      private int number;
      private String str;
  
      public Foo() {
          number = 10;
          str = "hello";
      }
  }
  </code></pre>
  
  <p>Gson will serialize this into a JSON</p>
  
  <p><code>{"number":10,"str":"hello"}</code>.</p>
  
  <p>However, I want it to be</p>
  
  <p><code>{"Foo":{"number":10,"str":"hello"}}</code>,</p>
  
  <p>so basically including the top level element. I tried to google a way to do this in Gson, but no luck. Anyone knows if there is a way to achieve this? </p>
  
  <p>Thanks!</p>