Client-side Serialization for HTML5 LocalStorage. JSON?

127 views
Skip to first unread message

Evan Ruff

unread,
Jun 16, 2011, 9:06:56 PM6/16/11
to google-we...@googlegroups.com
Hey guys,

Similar to my cache/manifest post, I'm trying to create the most lightweight JSON conversion algorithms I can. When I try to include a toJSON/fromJSON funciton in my beans, I'm getting nasty serialization errors. The problem lies in the com.google.gwt.json.client.* classes not being serializable. Is there any way I can get around the Serialization issue without having to remove the JSON imports in my class? I'd like to keep the code tidy by leaving the translation (to/from) methods in the beans, but not at the expense of RPC serialization.

The overall goal is to be able to serialize my beans on the client so that I can push them into a LocalStorage key. Is there a better way to do JSON serilzation on the client in GWT? I'd also be interested in any other serilazation stratgies that are lightweight, fast and useful on the client. 

Has anyone else tackled this problem? Thanks!

Evan

Harald Pehl

unread,
Jun 17, 2011, 3:28:45 AM6/17/11
to google-we...@googlegroups.com
Take a look at Piriti: http://code.google.com/p/piriti/. It's an XML / POJO mapper based on annotations and deferred binding. The actual mapping code is generated for you. You can have it inside your beans or configure the mapping in extra interfaces. Currently serialization to/from JSON is supported. 

- Harald

Thad

unread,
Jun 17, 2011, 9:53:45 AM6/17/11
to Google Web Toolkit
On the server side, I use the JSON code from http://www.json.org/java/index.html
and serialize a String across the GWT RPC boundary. It's a bit
different from GWT's client JSON, but it's worked for me.

Evan Ruff

unread,
Jun 17, 2011, 4:52:14 PM6/17/11
to google-we...@googlegroups.com
Ah thanks! This is what I was looking for.

Thanks!

E
Reply all
Reply to author
Forward
0 new messages