Skip to content

Custom serializers and deserializers

Nicolas Morel edited this page Dec 10, 2013 · 7 revisions

If you want to use your own serializers/deserializers instead of the default ones or handle a new type, you can do so by creating a class that extends com.github.nmorel.gwtjackson.client.AbstractConfiguration. Then register your class in your *.gwt.xml file with the property gwtjackson.configuration.extension :

<extend-configuration-property name="gwtjackson.configuration.extension" value="com.MyConfiguration" />

Inside the configure() method, you can define serializer and/or deserializer for :

  • primitive types :
primitiveType( boolean.class ).serializer( BooleanJsonSerializer.class ).deserializer( BooleanJsonDeserializer.class );
  • types :
type( String.class ).serializer( StringJsonSerializer.class ).deserializer( StringJsonDeserializer.class );
  • Map's key type :
key( UUID.class ).serializer( UUIDKeySerializer.class ).deserializer( UUIDKeyDeserializer.class );

For an example, you can look at the class com.github.nmorel.gwtjackson.rebind.DefaultConfiguration which is used internally to register all the default serializers and deserializers.

Clone this wiki locally