protected static JSONObject index(JSONObject view) throws Exception {
  JSONObject result = new JSONObject();
  JSONArray rows = view.getJSONArray("rows");
  for (int i=0; i<rows.length(); i++) {
    JSONObject r = rows.getJSONObject(i);
    JSONArray keys = r.getJSONArray("key");
    JSONObject current = result;
    for (int k=0; k<keys.length(); k++) {
      current = current.getJSONObjectOrCreate(
        keys.getString(k)
      );
    } 
    JSONObject value = r.getJSONObject("value");
    Iterator<String> v = value.keys();
    while (v.hasNext()) {
      String attribute = v.next();
      current.justAccumulate(
        attribute,
        value.get(attribute)
      );
    }
  }
  return result;
}