public JSONObject increment(String key) throws JSONException {
        Object value = opt(key);
        if (value == null) {
            put(key, 1);
        } else if (value instanceof Integer) {
            put(key, ((Integer)value).intValue() + 1);
        } else if (value instanceof Long) {
            put(key, ((Long)value).longValue() + 1);
        } else if (value instanceof Double) {
            put(key, ((Double)value).doubleValue() + 1);
        } else if (value instanceof Float) {
            put(key, ((Float)value).floatValue() + 1);
        } else {
            throw new JSONException("Unable to increment [" + quote(key) + "].");
        }
        return this;
    }