What's new? | Help | Directory | Sign in
Google
gwt-jsonizer
A JSON/JavaBeans translator for the Google Web Toolkit
  
  
  
  
    
Code License: Apache License 2.0
Labels: GWT, JSON, Beans, Java
Show all Featured Downloads:
gwt-jsonizer-0.0.1.zip
Join project
Project owners:
  andres.a.testi

This project was developed for the Juglar.org group, and allows you to 'Jsonize' (instead of 'Serialize') JavaBeans to JSON objects, and JSON objects to JavaBeans in the context of the Google Web Toolkit. For performance reasons, this API doesn't uses the GWT JSON API. The main concept in this API is the 'Jsonizer'. The Jsonizer, is an interface with the capability of 'jsonize' and 'dejsonize' JavaBeans. We can generically refer to 'jsonize' and 'dejsonize' actions simply as 'jsonize'. The Jsonizer interface, has only two methods: 'asJavaObject' and 'asString'. As possibly you can infer, the 'asJavaObject' method unjsonizes JSON values, and the 'asString' method, performs the opossite action. For Example:

// a Person bean class.
class Person{
  ...
  public String getName(){...}
  public void setName(String name){...}
  ...
  public int getAge(){...}
  public void setAge(int age){...}
}

/**
 * If you wants to jsonize it, you need to implement an extension of 
 * Jsonizer interface suffixed with the 'Jsonizer' keyword.
 */
interface PersonJsonizer extends Jsonizer{}

// A JSON String with Person properties
String json = '{'name':'Andres','age':28}';

// Create the Person Jsonizer
PersonJsonizer jsonizer = (PersonJsonizer)GWT.create(PersonJsonizer.class);
try{
  // Translate the JSON String to a Person bean
  Person p = (Person)JsonizerParser.parse(jsonizer, json);
}catch(JsonizerException e){
  Window.alert('JSON Translation Error!');
}