Hi Jose,

you could take a look at Piriti: http://code.google.com/p/piriti/.
It's an XML / JSON mapper for GWT which maps JSON data from the server
to POJO on the client.

- Harald

P.S. At the moment Piriti uses the "eval" function to parse JSON. This
will be changed in the next release, so that the internal JSON parser
is used.

On 18 Jun., 15:34, Chris Boertien <[email protected]> wrote:
> Shouldn't have a problem sending a HashMap back and forth. As far as i
> can tell GWT has a fairly complete implementation of the Java
> Collections API, and all of which are Serializable, so there shouldn't
> be any issues. I haven't used it for much more than Lists so there
> might be quirks I haven't come across yet.
>
> 2010/6/18 Jose Luis Estrella Campaña <[email protected]>:
>
>
>
> > Hello There !
>
> > I believe what Chris says is totally right, I should just use a
> > regular Java Object, I was mistaken when I thought I had to do JSON
> > parsing on the server side.
> > Now, I would like to know if a HashMap containing Strings only is
> > serializable ? Could I send it from the client to the Server and Back
> > (specially back)?
>
> > Thank you very much in advance !
>
> > Jose.
>
> > On Jun 17, 10:59 pm, Jan Ehrhardt <[email protected]> wrote:
> >> The GWT docs are offering you to use the JavaScript "eval" function 
> >> directly
> >> or through the JSONParser class, which internally uses the "eval" function.
> >> A more secure way, that is to use the JSON 
> >> libraryhttp://www.json.org/js.html. You'll place the additional JavaScript 
> >> library
> >> in your host page, as any other JavaScript too. Than take the code from the
> >> GWT docs:
>
> >> private final native JsArray<StockData> asArrayOfStockData(String json) 
> >> /*-{
> >>   return *eval(json);*
>
> >> }-*/;
>
> >> and modify it like this:
>
> >> private final native JsArray<StockData> asArrayOfStockData(String json) 
> >> /*-{
> >>   return *$wnd.JSON.parse(json);*
>
> >> }-*/;
>
> >> This is more secure than using the "eval" function. Additionally the
> >> "JSON.parse()" function has become part of the JavaScript standard and is
> >> implemented natively in many modern browsers. The above library knows this
> >> and delegates the secure JSON parsing to the fast native parser provided by
> >> the browser.
>
> >> Regards
> >> Jan Ehrhardt
>
> >> 2010/6/18 Chris Boertien <[email protected]>
>
> >> > Is there a particular reason that you _need_ the JSON string? If your
> >> > using GWT RPC then you can simply send a Java Object to the server and
> >> > the underlying GWT will handle the serialization for you.
>
> >> > If you the JSON string is coming from somewhere else and you really
> >> > have no choice, then it may be worthwhile to put together a JSO
> >> > Overlay, use the Overlay to instantiate a POJO on the client side
> >> > code, and send the POJO to the server via GWT RPC.
>
> >> > Since your new some of that probably makes no sense, and If you can
> >> > give a little more detail as to why you need to have JSON originating
> >> > from the client I'm sure this can be explained a bit better to fit
> >> > your case.
>
> >> > GWT-RPC:http://code.google.com/webtoolkit/doc/latest/tutorial/RPC.html
> >> > GWT-JSON:
> >> >http://code.google.com/webtoolkit/doc/latest/tutorial/JSON.html#client
>
> >> > 2010/6/16 Jose Luis Estrella Campaña <[email protected]>:
> >> > > Hello Folks !
>
> >> > > I'm glad to say that I'm a brand new user of GWT, a very happy one by
> >> > > the way. However, as any newcomer I have questions, One in particular.
> >> > > Here it goes:
>
> >> > > What's the easiest, most straight forward way to deserialize a JSON
> >> > > String on the Server side and instance a Java Object from it ?
>
> >> > > The JSON String will be sent from the client side, an implementation
> >> > > of the RemoteService for example, and I intend to deserialize it on
> >> > > the Server side, say inside the RemoteServiceServlet Implementation,
> >> > > so I can instance a Java Object with the information contained in the
> >> > > JSON string afterwards. Is there a way this last step automatically
> >> > > with some GWT API ?
>
> >> > > I would like to see some examples if it's possible.
>
> >> > > Best Regards,
>
> >> > > Sincerely,
>
> >> > > Jose.
>
> >> > > --
> >> > > 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]<google-web-toolkit%2Bunsubs
> >> >  [email protected]>
> >> > .
> >> > > For more options, visit this group at
> >> >http://groups.google.com/group/google-web-toolkit?hl=en.
>
> >> > --
> >> > 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]<google-web-toolkit%2Bunsubs
> >> >  [email protected]>
> >> > .
> >> > For more options, visit this group at
> >> >http://groups.google.com/group/google-web-toolkit?hl=en.
>
> > --
> > 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 
> > athttp://groups.google.com/group/google-web-toolkit?hl=en.

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