I am trying to generate a proper JSON output for use with jQuery UI Autocomplete. I am forced to use the JAVA json-simple lib and I tried every combination that I could think of.
Lets suppose that I like the drop down to show a list of "Alex1", "Alex2", "Alex3" etc.
I have tried the following
JSONObject obj =new JSONObject();
List strs = new ArrayList();
strs.add("Alex1");
strs.add("Alex2");
strs.add("Alex3");
strs.add("Alex4");
obj.put("source", strs);
return(obj.toJSONString());
And I have also tried
JSONObject obj =new JSONObject();
Map map = new LinkedHashMap();
map.put("id1", "Alex1");
map.put("id2", "Alex2");
map.put("id3", "Alex3");
map.put("id4", "Alex4");
obj.put("source", map);
return(obj.toJSONString());
But with no luck
I have tried to return a String made by hand in the proper format and my module works perfectly so I know that the problem is on the JSON output.
an someone tell me how can I set it properly using the json-simple lib??
Thanks