With GWT, how would I go about looping through a JSON object or array, which has been returned via a JSNI method, that I could also extract both name and value pairs per loop?
1 Answer
Are you using JavaScriptOverlay types or JSONObject like types?
So in case of JSONObject like types and assuming data is of type JSONObject you can do following:
json_string = "{'data':{'key':'test','key2':'test3','key3':'test3'}}"
JSONObject json_data = JSONParser.parseLenient(json_string);
JSONObject data = json_data.get("data").isObject();
Set<String> keys = data.keySet();
for (String key : keys)
{
String value = data.get(key).isString().stringValue();
}