I am currently deserializing JSON using XStream, and it has been working great. However, when I have JSON string like the following
{
key1: { an_object: { something: 'foobar' } },
key2: { another_object: { data: 'hi' }
}
most notably it doesn't have a root node, I'm not sure how to parse it. Basically, I want the opposite of DROP_ROOT_NODE for the deserialization.
The short answer is "you can't".
XStream needs to know what class to instantiate, it gets that knowledge from JSON (or XML) data. Class name can be aliased, but it can not be omitted. You can work around by: