I found this which might be of some help to you...

        private void myfunc(TreeItem treeItem, JSONValue jsonValue) {
            JSONArray jsonArray;
            JSONObject jsonObject;
            JSONString jsonString;

            if ((jsonArray = jsonValue.isArray()) != null) {
                for (int i = 0; i < jsonArray.size(); ++i) {
                    TreeItem child = treeItem.addItem(getChildText("[" +
Integer.toString(i) + "]"));
                    myfunc(child, jsonArray.get(i));
                }
            } else if ((jsonObject = jsonValue.isObject()) != null) {
                Set keys = jsonObject.keySet();
                for (Iterator iter = keys.iterator(); iter.hasNext();) {
                    String key = (String) iter.next();
                    TreeItem child = treeItem.addItem(getChildText(key));
                    myfunc(child, jsonObject.get(key));
                }
            } else if ((jsonString = jsonValue.isString()) != null) {
                treeItem.addItem(jsonString.stringValue());
            } else {
                treeItem.addItem(getChildText(jsonValue.toString()));
            }
        }
        private String getChildText(String text) {
            return "<span style='white-space:normal'>" + text + "</span>";
        }

Here actually I am parsing data and forming a tree of the JSON object. :)

Cheers,
Amit Dhingra



On Mon, Sep 22, 2008 at 11:50 PM, seven.reeds <[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> This is probably not a GWT issue but I am really still a java newbie.
> I have a JSONObject and one element in the thing is itself an
> associative array of items.
>
> I know I can use the has() & get() methods to get to the this "sub-
> object".  I am sure I can use the keys() method on the sub object to
> get a java.util.Iterator.
>
> My question is how can I process the list of keys in some order that
> is determined at run time?
> >
>


-- 
Warm Regards,
Amit Dhingra

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to