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