title: Gson serializing a bean
body: <p>When I have an entity like this</p>
  
  <pre><code>class Foo
  {
     private String Bar = "someBarValue";
  }
  </code></pre>
  
  <p>and the following statement</p>
  
  <pre><code>String json = new Gson().toJson(new Foo());
  </code></pre>
  
  <p>results in <code>{ "bar" : "someBarValue"}</code></p>
  
  <p>I have lots of classes that follow the standard java bean convention</p>
  
  <pre><code>class FooBean
  {
      String getBar() { return "someBarValue"; }
  }
  </code></pre>
  
  <p>and the following statement</p>
  
  <pre><code>String json = new Gson().toJson(new FooBean());
  </code></pre>
  
  <p>results in <code>{}</code></p>
  
  <p>How can I serialize (and eventually deserialize, if I have setters) <code>FooBean</code> from the above example using Gson without having to rely on the private member variables of a class?</p>