I can't seem to find this anywhere, but tons of people have to be doing this.
I have an array of objects that I want to convert to a JSON String and post to a REST URL. Here's what I have so far:
if(history==null||history.length == 0){
return new String[0];
}
JSONArray array = new JSONArray();
for(DeviceHistory connectHistory:history){
array.put(connectHistory);
}
JSONObject response = jsonClient.remoteCall(SERVICE_NAME, array.toString());
The problem is that I get ["com.abc.model.connect.DeviceHistory@41e63298","com.abc.model.connect.DeviceHistory@41e63760","com.abc.model.connect.DeviceHistory@41e63c28","com.abc.model.connect.DeviceHistory@41e640f0"] from array.toString(). What am I doing wrong?