Activate your free membership today | Log-in

Tuesday, April 17th, 2007

GWT-Jsonizer: JSON/JavaBeans translator

Category: GWT, JSON, Library

<p>Andrés Testi has developed a JSON/JavaBean translator for the Google Web Toolkit named GWT Jsonizer, which simplifies the
GWT interaction with non-java backends.

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 opposite action.

Example

JAVA:
  1.  
  2. /**
  3. * If you wants to jsonize it, you need to implement an extension of
  4. * Jsonizer interface suffixed with the 'Jsonizer' keyword.
  5. */
  6. interface PersonJsonizer extends Jsonizer{}
  7.  
  8. // A JSON String with Person properties
  9. String json = '{'name':'Andres','age':28}';
  10.  
  11. // Create the Person Jsonizer
  12. PersonJsonizer jsonizer = (PersonJsonizer)GWT.create(PersonJsonizer.class);
  13. try{
  14.   // Translate the JSON String to a Person bean
  15.   Person p = (Person)JsonizerParser.parse(jsonizer, json);
  16. }catch(JsonizerException e){
  17.   Window.alert('JSON Translation Error!');
  18. }
  19.  

Related Content:

  • U2E
    Unreal Game...
  • TBU
    PASSOLO Translation...
  • UK
    English language translation...
  • TRX
    PASSOLO translation...
  • TBA
    PASSOLO Licensed Translation...

Posted by Dion Almaer at 5:58 am
Comment here

++++-
4 rating from 22 votes

Comments Here »

Comments feed TrackBack URI

Leave a comment

You must be logged in to post a comment.