ArrayList > JSONObject

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

dingo
Posts: 98
Joined: 27 Jan 2009, 21:34

ArrayList > JSONObject

Postby dingo » 09 Sep 2009, 16:40

hi,

just a quick question from a java newbie.

what would be the easiest way to cast the output from the dbManager.executeQuery (an ArrayList) to a JSONObject so i can send it back to the client.

Do i have to cycle through each row in the ArrayList and add the items manually?

thanks.
dingo
Posts: 98
Joined: 27 Jan 2009, 21:34

Postby dingo » 09 Sep 2009, 18:36

ok i think i've found a way:

Code: Select all

       
        ArrayList<DataRow> queryRes = dbManager.executeQuery(sql);

        if (queryRes != null && queryRes.size() > 0)
        {
            int queryResLength = queryRes.size();

            for(int i=0; i < queryResLength; i++)
            {
                DataRow row = queryRes.get(i);
                jso.add(row.getDataAsMap());
            }
        }
        return jso;
[/code]

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 21 guests