Oh, one mistake in my above sample:

The methods of the Report class shouldn't me static.

Regards
Jan Ehrhardt

On Tue, Jan 5, 2010 at 10:23 AM, Jan Ehrhardt
<jan.ehrha...@googlemail.com>wrote:

> Hi Jeff,
>
> I don't know why you're binding a Report object to $wnd, but in a standard
> case JSON usage would look the following way:
>
> public class Report extends JavaScriptObject {
>
>     protected Report() {}
>
>     public final static native Report getName() /*-{
>         return this.name;
>     }-*/;
>
>     public final static native void setName(String name) /*-{
>         this.name = name;
>     }-*/;
> }
>
> An incoming JSON string looking like this
>
> {name: "My Report"}
>
> can be parsed the following this way
>
> JSONObject obj = JSONParser.parse(response.getText()).isObject();
> if(obj != null) {
>   Report myReport = obj.getJavaScriptObject().cast();
>   // do something with myReport
> }
>
> This has the benefit, that the object only lives as inside your GWT app,
> instead of affecting other things.
>
> On Mon, Jan 4, 2010 at 4:01 PM, Jeff Chimene <jchim...@gmail.com> wrote:
>
>> Sri,
>>
>> Thanks.
>>
>> I have a question:
>> <snip>
>>
>>> *Performance*
>>>
>>>    - Client Side - REST with JSON wins over RPC. Browsers are
>>>    exceptionally good at json parsing. It is going to be much faster than 
>>> GWTs
>>>    serialization/deserialization mechanism. This is applicable only if you 
>>> use
>>>    javascript overlays. JSONArray/JSONObject/JSONValue classes don't give 
>>> you
>>>    this performance benefit.
>>>
>>>
>> I've been using the following technique to use the JSON parsing in 2.0. I
>> don't see a specific example in the docs:
>>
>>
>> Report.set(JSONParser.parse(response.getText()).isObject().getJavaScriptObject());
>>
>> Where Report is defined as follows:
>>
>> public class Report extends JavaScriptObject {
>>
>>     protected Report() {}
>>
>>     public final static native Report get() /*-{
>>         return $wnd.Report;
>>     }-*/;
>>
>>     public final static native void set(JavaScriptObject value) /*-{
>>         $wnd.Report = value;
>>     }-*/;
>> }
>>
>> I don't see any other way to avoid unsafe parsing.
>>
>> Comments?
>> <snip>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google Web Toolkit" group.
>> To post to this group, send email to google-web-tool...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com>
>> .
>> 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 google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.


Reply via email to