public JSONObject put(String key, Object value) throws JSONException {
if(value == null) {
try {
delegate.put(key, value);
} catch (Exception ex) {
JSONException jex = new JSONException(ex.getMessage());
jex.initCause(ex);
throw jex;
}
} else {
try{
Class clazz = value.getClass();
if (org.apache.wink.json4j.compat.impl.ApacheJSONObjectDelegate.class.isAssignableFrom(clazz)) {
this.delegate.put(key, ((org.apache.wink.json4j.compat.impl.ApacheJSONObjectDelegate)value).delegate);
} else if (org.apache.wink.json4j.compat.impl.ApacheJSONArrayDelegate.class.isAssignableFrom(clazz)) {
this.delegate.put(key, ((org.apache.wink.json4j.compat.impl.ApacheJSONArrayDelegate)value).delegate);
} else if (Number.class.isAssignableFrom(clazz)) {
this.delegate.put(key, value);
} else if (Boolean.class.isAssignableFrom(clazz)) {
this.delegate.put(key, value);
} else if (String.class.isAssignableFrom(clazz)) {
this.delegate.put(key, value);
}
} catch (Exception ex) {
JSONException jex = new JSONException(ex.getMessage());
jex.initCause(ex);
throw jex;
}
}
return this;
}