On 04/03/2013 11:20 PM, Jörg Schaible wrote:
Hi,

Xybek wrote:

On 04/03/2013 04:28 PM, Jörg Schaible wrote:
Hi,

Xybrek wrote:

Hello,

I'm getting this error when trying to "deserialize":

Cannot construct MyClass as it does not have a no-args constructor.

Looking at the docs, it means that Xtream is not running in enhanced
mode?

However, in the same JVM and using the same class the Google Gson
library can serialize and deserialize objects without problem:

MyClass c;
c = (MyClass) new Gson().fromJson(json, MyClass.class);

So why Xstream can't do to XML what Gson can do for JSON? Is this easy
to patch in the Xstream code or is this a limitation that is not easy to
get around with?

XStream will normally run always in enhanced mode. Which version of
XStream you're using, which Java version and vendor? Is it a special
environment (e.g. app server or applet)? How did you initialize XStream?

Hi Jorg,

I just did a simple:

XStream xstream = new XStream();

I thought you tried to process JSON? Did you actually read XStream's JSON
tutorial?

I'm using JDK 1.7 64-bit (from Oracle), just running a JUnit test.

Which version of XStream?

What makes me think is that why Gson can deserialize a no-args
constructor in the same JVM and same JUnit test

Can't say, because in XStream's ~1500 unit tests it does this more than
once.

Can you post the complete exception including stack trace?

- Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

     http://xircles.codehaus.org/manage_email




ps. I think the XML marshalling is what I like the most than representing Object as JSON, I just pointed out that I tried Gson and that it process JSON strings comparing to XStream. The XML processing is what I need, and hopefully deal with Object graphs.

-Xybrek


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to