On Monday, February 4, 2013 4:32:52 PM UTC+1, membersound wrote:
Hi,
I serialize one of my beans with AutoBeanCodex.encode(bean).getPayload();
But when I'm trying to import and decode the same string, I do not want the AutoBean Proxy Object. I just want to have the JSONObject itself.
The following will still give me the AB Proxy. How can I get the "real" object?
MyBeanInterface bean = AutoBeanCodex.decode(factory, MyBeanInterface.class, jsonString).unwrap();
Can't you just do a new JSONObject(jsonString) (or JSONPArser.parseStrict(jsonString).isObject(), depending which JSONObject you're talking about)
Alternatively, if you want a JavaScriptObject, use JsonUtils.safeEval(jsonString);
java.lang.IllegalStateException
at com.google.web.bindery.autobean.shared.impl. AbstractAutoBean.unwrap( AbstractAutoBean.java:173)
at My.deserialize(My.java:40)
Why am I getting a exception if I'm decoding a Autobean the "same" way as I'm serializing it?
unwrap() is for the case when you're wrapping an instance of some object implementing the MyBeanInterface interface inside an AutoBean (when your AutoBeanFactory has a method that takes a MyBeanInterface argument and returns an AutoBean<MyBeanInterface> or when you use the AutoBeanFactory#create() that takes 2 arguments)
-- 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment