Right.  Its harder with the overlay types to define a map or something like
that.  You could try to wrap the JavaScriptObject with some class that knows
to convert a list in native JS into a Java Map, but at that point you have
about half of GWT's own RPC system, or gwtjsonrpc.  This case of wanting
rich Java types but a clear JSON encoding is why I wrote gwtjsonrpc.

A thought just occured to me though; a JSON "map" would typically be an
object with the keys being the property names...  but JSON only permits
strings for the property names and you mention wanting some other types.
gwtjsonrpc should support any Object type in the key (so long as it is
declared to be a concrete type in the Map<> type parameter), but for non
string typed key maps gwtjsonrpc uses a JSON array of pairs (even index is
key, odd is value).  I'm not sure what sort of encoding you were looking for
or needing here...  (for Map<String,...> it uses the standard object
notation).

On Dec 17, 2008 11:12 AM, "Clint Gilbert" <
[email protected]> wrote:


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

> On Tue, Dec 16, 2008 at 18:34, [email protected]<mailto:
clint.gilb...@childrens....
> 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. >...
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

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

--~--~---------~--~----~------------~-------~--~----~ You received this
message because you are su...

--~--~---------~--~----~------------~-------~--~----~
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