Hi Jason,

Jason Novotny wrote:

> 
> Hi,
> 
>      I have a class OrderRequest, I show my fields below (there are
> set/get for each field, not displayed)
> 
> public class OrderRequest implements Serializable {
>      private Long id;
>      private String accountName;
>      private Date timeStamp;
>      private OrderAction orderAction;
>      private String name;
>      private String symbol;
>      private Double amount;
>      private OrderConfirmation orderConfirmation;
> }
> 
> I'm converting some JSON to an object doing the following:
> String json =
> "{\"id\":1,\"accountName\":\"assdd\",\"timeStamp\":null,
\"orderAction\":null,\"name\":null,\"symbol\":\"fjhhhj\",\"amount\":453.0,
\"orderConfirmation\":null}
> ";
> XStream xstream = new XStream(new JettisonMappedXmlDriver());
> OrderRequest t = (OrderRequest) xstream.fromXML(json);
> 
> and then I get:
> 
> com.thoughtworks.xstream.mapper.CannotResolveClassException: id
>      at
> 
com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:56)
>      at
> 
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
> 
> If I use XML instead of JSON it works fine....

This JSON string is like deserializing XML without root element. That won't 
work also.

If you produce JSON from that object you will get something like:

{ "OrderRequest": { "id": 1, ...  }}

The difference is obvious.

Cheers,
Jörg


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

    http://xircles.codehaus.org/manage_email


Reply via email to