Deserializing/serializing JSON with GWT

A fairly typical use case: a GWT server-side component serializes java objects into Json, to be consumed by GWT clients.

Server-side serialization is actually very easy thanks to the google-gson library.
It's literally a one-liner:

String json =new Gson().toJson(myObject);

On the client side things are a little bit more complicated. Gson (or any other library with features which are not supported on a GWT client such as reflection, dynamic class-loading, multithreading... ) cannot be used.

Yo know, that you send the object back to server using GWT-RPC, just to create a JSON string? The standard use case of JSON in GWT client code is for serverinteraction. So you make a call to the GWT ServerCode to create a string, which you will send to sevrer again.