-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Thanks very much, I'll take a look at wgtjsonrpc.

My app needs to serialize a non-trival map of data: String => Date-range class 
=> other
user-defined type => data POJO, currently.  I'm familiar with Overlay types, 
and somewhat
familiar with JSNI, so I think I could write a class that wraps a 
JavaScriptObject and
uses that handle as the backing map.  Then I could just serialize the wrapped 
JSO.  But
then I'd lose some useful features of a Java Map, like being able to use 
non-primitive
types for keys, nice methods like keySet(), etc, no?

Shawn Pearce wrote:
> Roll your own, or look at gwtjsonrpc:
> 
>   
> http://android.git.kernel.org/?p=tools/gwtjsonrpc.git;a=blob;f=README;hb=HEAD
> 
> You can also look at JSNI and the JavaScriptObject subclassing tricks in the 
> GWT documentation (under JavaScript Integration) to build Java objects that 
> are more directly JavaScript entities, and thus more easily serialized with 
> JavaScript JSON libraries.
> 
> On Tue, Dec 16, 2008 at 18:34, 
> [email protected]<mailto:[email protected]>
>  
> <[email protected]<mailto:[email protected]>>
>  wrote:
> 
> I'm sorry if this has already been answered, but after searching a bit
> I didn't come up with any answers.  Does anyone know of a way to
> serialize objects to JSON on the client side?  Ideally, it would work
> similarly to the json2.js lib from json.org<http://json.org> that I was using 
> prior to
> moving to the GWT, but anything relatively straightforward that
> performs well is fine with me.
> 
> I tried wrapping the json2.js lib in a native method that calls
> $wnd.JSON.stringify():
> 
> public abstract class JSONSerializer
> {
>    public static final native String serialize(final Object object)/*-
> {
>        return $wnd.JSON.stringify(object);
>    }-*/;
> }
> 
> but it pins my CPU and runs for several minutes when serializing
> anything but a trivial object.  The problem seemed to be the verbosity
> (completeness?) of the object when marshalled across the Java-
> toJavascript boundary by the GWT.  I'd also like to control the
> mapping of Java properties to JSON ones.
> 
> Surely there's a better way?  Or will I have to roll my own?
> 
> 
> 
> 
> > 
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFJSU+ErZoE3ArapxERCFm6AKCBhbEn83de4ivjGGgBAagpEAFGaQCeIDJL
3xJzW9oU0UXdC9WuiFUbm3M=
=/zOi
-----END PGP SIGNATURE-----


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to