This is not totally true, gwt-rpc is OK for most data transfers, but
it causes a bit of overhead in deserialization. GWT's client side JSON
library is SLOW,
it constructs a parallel data structure of concrete types on parse,
upfront, and by default uses eval('''), which isn't always the best or
fastest way to go.

Since your asking the JSON data-structure "isArray()", etc, most of
the time, I find lazy evaluation to be much faster. Also, you can
tweak your custom deserializer to use the JSON
native parser if it is available.

On Jun 18, 2:14 pm, Gal Dolber <[email protected]> wrote:
> Sure, there is no doubt that the best way to go its the gwt-rpc
>
> 2010/6/18 Chris Boertien <[email protected]>
>
>
>
> > All good points, but I think you guys are totally missing the point.
> > He was taking a POJO and converting it to JSON for transmission using
> > GWT-RPC, which is completely redundant since GWT-RPC can simply send
> > the POJO and handle all the messy bits for him.
>
> > Simple is better...
>
> > On Fri, Jun 18, 2010 at 9:26 AM, Gal Dolber <[email protected]> wrote:
> > > I think the best you can do is a generator that creates an overlay for
> > that
> > > pojo and a utility class to convert a json string to the pojo.
> > > The interface will look like this:
> > > public interface Json2Pojo<POJO> {
> > > POJO fromJson(String json);
> > > }
> > > And the steps will be:
>
> > > Create an POJOOverlay from the json string
> > > Instantiate a POJO
> > > Call all POJO setters with POJOOverlay getter
> > > Return the POJO
>
> > > And the gwt compiler will inline that for you.
> > > Best
> > > 2010/6/18 Peter Simun <[email protected]>
>
> > >> Hi Jose,
>
> > >> Piriti project looks great for your needs. If you would like to
> > >> customize deserialization process (with custom instantiators and
> > >> deserializers) you can also use acris-json project. You can find
> > >> details here:
> > >>http://code.google.com/p/acris/wiki/GWTJsonizer
>
> > >> (Project is based on JSONParser from GWT which internally use eval
> > >> function)
>
> > >> Only with using annotations you can get powerfull piece of
> > >> functionality in JSON parsing mechanism. For example this project was
> > >> used for deserialize JSON reponses from Google Youtube API in gwt-
> > >> youtube-api.googlecode.com project.
>
> > >> Peter
>
> > >> On 18. Jún, 16:14 h., Harald Pehl <[email protected]> wrote:
> > >> > 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]>
> > <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]>
> > <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
> > >> > > > 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]<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
>
> ...
>
> read more »

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