docs: static String valueToString(Object value) throws JSONException {
      if (value == null || value.equals(null)) {
        return "null";
      }
      if (value instanceof JSONString) {
        Object o;
        try {
          o = ((JSONString) value).toJSONString();
        } catch (Exception e) {
          throw new JSONException(e);
        }
        if (o instanceof String) {
          return (String) o;
        }
        throw new JSONException("Bad value from toJSONString: " + o);
      }
      if (value instanceof Number) {
        return numberToString((Number) value);
      }
      if (value instanceof Boolean || value instanceof JSONObject || value instanceof JSONArray) {
        return value.toString();
      }
      if (value instanceof Map) {
        return new JSONObject((Map) value).toString();
      }
      if (value instanceof Collection) {
        return new JSONArray((Collection) value).toString();
      }
      if (value.getClass().isArray()) {
        return new JSONArray(value).toString();
      }
      return quote(value.toString());
    }