I want to create a JSON object. I have tried the following
myString=new JSONObject().put("JSON", sampleClass).toString();
but mystring gives me {"SampleClass@170f98"}.
I also tried the following
XStream xsStream=new XStream(new JsonHierarchicalStreamDriver());
SampleClass sampleClass=new SampleClass(userset.getId(),userset.getUsername());
myString=xsStream.toXML(sampleClass);
It works but when i use getJSON in javascript to get myString it does not work.