JSONArray options = new JSONArray(); for(Group group : List<Group> groups) { JSONObject obj = new JSONObject(); obj.put(group.getId, group.getName()); options.put(obj); }
Cheers, Lance. 2008/5/14 Leon Derks <[EMAIL PROTECTED]>: > Can you give me an example of that? > > Leon > > > Lance Java wrote: > >> You want a JSONObject not a JSONArray >> http://tapestry.formos.com/nightly/tapestry5/apidocs/index.html >> >> Cheers, >> Lance. >> >> 2008/5/14 Leon Derks <[EMAIL PROTECTED]>: >> >> >> >>> Hello >>> >>> I found this example: >>> >>> new JSONArray("[['a', 'value a'], ['b', 'value b'], ['c', 'value c'], >>> ['d', >>> 'value d']]")); >>> >>> The JSONArray contains information for my select box, with a value - >>> label >>> pair. >>> >>> But in my case, I want to make a new JSONArray filled with properties >>> from >>> my List of Groups. >>> >>> So for example something like this: >>> >>> for(Group group : List<Group> groups) { >>> jsonArray.put(group.getId, group.getName()); >>> } >>> >>> The problem is that a put operation only allows put(Object value) and >>> put(int index, Object value); >>> >>> How can I add the group.getId and group.getName() as a value-label pair >>> to >>> the JSONArray? >>> >>> Leon >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [EMAIL PROTECTED] >>> For additional commands, e-mail: [EMAIL PROTECTED] >>> >>> >>> >>> >> >> >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >