I\'m currently writing a web application in java using GWT 2.0 in eclipse. I wanted to know if there is a way to use Gson library in a GWT application\'s client cod
Not exactly what you wrote but I guess that what you meant was how to serialize/deserialize JSON in GWT code?
In GWT 2.1.1 you can use GWT AutoBean framework
See there at the bottom of the article it has this magic code ...
String serializeToJson(Person person)
{
// Retrieve the AutoBean controller
AutoBean bean = AutoBeanUtils.getAutoBean(person);
return AutoBeanCodex.encode(bean).getPayload();
}
Person deserializeFromJson(String json)
{
AutoBean bean = AutoBeanCodex.decode(myFactory, Person.class, json);
return bean.as();
}
the serializeToJson() woks fine for me even with instances that are inherit Person but I did not try the deserializeFromJson...