We have use GWT Platform with GWTP client and rest web services within GUICE container. Rest service invocation from GWT client is done using JSONPRequestbuilder.
I want to know which is the best JSON response string parsing technique for GWT? – JSON to Java serialization/deserialization
After lot of search on google, I found out that we have these many options.
- GWT built in JSONParser parseStrict method which is called secured and best way to go. But this may not be suitable for complex JSON response string. Becuase you need to write lot of code to parse each item in JSON response and convert to a Java object.
- GWT AutobeanFactory approach – I dont know how best to use this? We are using GWT 2.4, you do not have any complete example of using this approach at all. Everywhere, people say its an approach but no where we have detailed description on this. Few samples on google were from gwt older versions which were changed a lot in GWT 2.4. Please somebody share a good example with GWT 2.4 and Autobean factory approach for JSON ser/deser…
- JavaScript overlay types: People say it is not the secured way to go. So I am bit hesitate whether we should use this or not.
Moreover, we are migrating from GWT to SmartGWT very soon. I hope, the rest call services with these should continue to work even in SmartGWT without any changes. (Because SmartGWT also comes with a predefined format JSON rest support which we may not use as we already have built these services in general).
If you need introspection (you don’t have a strict schema for your JSNO objects), then use the
JSONParser.You could also use, with a slightly easier to use API but not documented at all,
com.google.web.bindery.autobean.shared.Splittable(more specifically theJsonSplittablein DevMode, and theJsoSplittablein prod mode).If you have a strict schema, then use either JSO overlay types or AutoBean. AutoBean has a slight overhead compared to JSOs, but allows the use of
List,SetandMapinstead ofJsArrayand custom JSOs. AutoBean can also be used on the server-side or from non-GWT Java clients, via theAutoBeanFactorySource. This can also be useful for unit-tests where you don’t need a sluggishGWTTestCase, contrary to JSOs.You can find an example of AutoBean in its official documentation: http://code.google.com/p/google-web-toolkit/wiki/AutoBean
As for security, as long as you use
parseStrict(which AutoBean uses under-the-hood, so no worries), then you’re safe. JSOs won’t be any less secure than AutoBean orJSONParser(orSplittable).