Tuesday, August 27, 2013

Re: JSON object to AutoBean via JSNI in DevMode

Use native JSON.stringify through JSNI?
The problem with com.google.gwt.json is that it creates a lot of objects and uses a lot of JSNI which slows down DevMode.

Ok JSON.stringify helps quite a bit. Now its basically

if (GWT.isScript()) {
  dataBean = AutoBeanCodex.decode(factory, Data.class, (JsoSplittable) getDataAsJsoFromJSNI());
} else {  
  //JsoSplittable is @GwtScriptOnly so we need something different for DevMode
  dataBean = AutoBeanCodex.decode(factory, AppInitData.class, getDataAsStringFromJSNI());
}




(side note: the data you get from the page is JS, not JSON; JSON is a serialization format, if you have objects, then it's JS, possibly expressed as JS literals; this is one reason why JSON-P is completely misnamed: there's no JSON in JSON-P, at all)

Yeah of course I get a JSO. Just a bad habit when naming it directly JSON.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment