this.toJSONString returns a JSON string, a well-formatted json string. "the_whole_json_stuff" was just my way of asking to actually how to get the deserialize the whole json string without actually specifying a node in the string like:
xstream.alias("product", Product.class); So how do you deserialize a JSON string with XStream? On Wed, May 15, 2013 at 6:41 AM, Jörg Schaible <joerg.schai...@gmx.de>wrote: > Hi, > > xybrek wrote: > > > I'm trying to deserialize a JSON string with XStream like this: > > private <T> T createTObjectWithXStream(Class<T> clazz){ > > XStream xstream = new XStreamGae(new JettisonMappedXmlDriver()); > > T obj = null; > > try { > > String json = this.toJSONString(); > > obj = (T) xstream.fromXML(json); > > } catch (Exception e) { > > LOG.log(Level.SEVERE, "XStream cannot deserialize this object: " + > > e.getMessage()); > > } > > return obj; > > } > > > > I need to deserialize the whole String as a type of clazz. However from > > the examples I need to do like: > > > > xstream.alias("product", Product.class); > > > > However, this seems for deserializing specific node, what should be done > > for working on the whole json string? Like > > > > xstream.alias("the_whole_json_stuff", clazz); > > > > Also the result of e.getMessage is 'contentType' what's that suppose to > > mean? > > > So, what is 'this'? What is 'json'? What do you mean with > "the_whole_json_stuff"? > > Sorry, but I don't get a clue what you try to ask. > > - Jörg > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > >