code: public JSONObject toJSONObject(JSONArray names) throws JSONException {
          JSONObject result = new JSONObject();
          int length = Math.min(names.length(), values.size());
          if (length == 0) {
              return null;
          }
          for (int i = 0; i < length; i++) {
              String name = JSON.toString(names.opt(i));
              result.put(name, opt(i));
          }
          return result;
      }
docs: Returns a new object whose values are the values in this array, and whose
  names are the values in {@code names}. Names and values are paired up by
  index from 0 through to the shorter array's length. Names that are not
  strings will be coerced to strings. This method returns null if either
  array is empty.