I have this JavaScript code:
$.cometd.publish('/service/slideshow/add_ids', {"list":[1889, 1888, 1887, 1886, 1885, 1884]});
In my Java code I have:
Map<String,Object> data = message.getDataAsMap();
if(data.containsKey("list"))
{
JSONObject o1 = new JSONObject(data);
String idList = o1.toString();
}
and my string 'idList' ends up being:
{"list":"[Ljava.lang.Object;@41c271b8"}
I have successfully published non-arrays and parsed them out correctly, but I can't seem to get arrays to work. Am I doing something wrong? Or is it not supported?
Thanks in Advance.
Try using JSONArray
instead.
Map<String, Object> data = message.getDataAsMap();
if(data.containsKey("list"))
{
JSONArray ja = new JSONArray(data.get("list"));
String idList = ja.toString();
}