When i use
new XStream().toXml(someObject);
it returns following xml...
<response>
<status>SUCCESS</status>
<isOwnershipVerified class="boolean">false</isOwnershipVerified>
</response>
and, when i use
new XStream(new JsonHierarchicalStreamDriver()).toXml(someObject);
it returns following json...
{"response": {
"status": "SUCCESS",
"isOwnershipVerified": {
"@class": "boolean""false"}
}}
Now, since i want to get rid of class attribute altogether (read it not to alias it with anything else, but to remove it) i use following code.
XStream xStream = new XStream();
StringWriter writer = new StringWriter();
xStream.marshal(this, new PrettyPrintWriter(writer) {
@Override
public void addAttribute(final String key, final String value)
{
if (!key.equals("class"))
{
super.addAttribute(key, value);
}
}
});
return writer.toString();
which gives follwing xml...
<response>
<status>SUCCESS</status>
<isOwnershipVerified>false</isOwnershipVerified>
</response>
but, when i pass new JsonHierarchicalStreamDriver() while xStream object creation above, it does NOT return json. it returns the same xml shown above.
What is wrong going on here?
Thanks in advance...