Gets a JSONObject-compatible value for the given object.
770122
private Object getJSONValue(Object value) throws JSONException {
    if (value instanceof Bundle) {
      return getJSONForBundle((Bundle) value);
    } else if (value instanceof CharSequence) {
      return value.toString();
    } else if (value instanceof List) {
      JSONArray array = new JSONArray();
      for (Object listValue : (List<?>) value) {
        array.put(getJSONValue(listValue));
      }
      return array;
    } else if (value instanceof SparseArray) {
      JSONArray array = new JSONArray();
      SparseArray<?> sparseValue = (SparseArray<?>) value;
      for (int i = 0; i < sparseValue.size(); i++) {
        array.put(sparseValue.keyAt(i), getJSONValue(sparseValue.valueAt(i)));
      }
      return array;
    } else if (value instanceof Character) {
      return value.toString();
    } else if (value instanceof Boolean) {
      return value;
    } else if (value instanceof Number) {
      if (value instanceof Double || value instanceof Float) {
        return ((Number) value).doubleValue();
      } else {
        return ((Number) value).longValue();
      }
    } else if (value instanceof boolean[]) {
      JSONArray array = new JSONArray();
      for (boolean arrValue : (boolean[]) value) {
        array.put(getJSONValue(arrValue));
      }
      return array;
    } else if (value instanceof char[]) {
      JSONArray array = new JSONArray();
      for (char arrValue : (char[]) value) {
        array.put(getJSONValue(arrValue));
      }
      return array;
    } else if (value instanceof CharSequence[]) {
      JSONArray array = new JSONArray();
      for (CharSequence arrValue : (CharSequence[]) value) {
        array.put(getJSONValue(arrValue));
      }
      return array;
    } else if (value instanceof double[]) {
      JSONArray array = new JSONArray();
      for (double arrValue : (double[]) value) {
        array.put(getJSONValue(arrValue));
      }
      return array;
    } else if (value instanceof float[]) {
      JSONArray array = new JSONArray();
      for (float arrValue : (float[]) value) {
        array.put(getJSONValue(arrValue));
      }
      return array;
    } else if (value instanceof int[]) {
      JSONArray array = new JSONArray();
      for (int arrValue : (int[]) value) {
        array.put(getJSONValue(arrValue));
      }
      return array;
    } else if (value instanceof long[]) {
      JSONArray array = new JSONArray();
      for (long arrValue : (long[]) value) {
        array.put(getJSONValue(arrValue));
      }
      return array;
    } else if (value instanceof short[]) {
      JSONArray array = new JSONArray();
      for (short arrValue : (short[]) value) {
        array.put(getJSONValue(arrValue));
      }
      return array;
    } else if (value instanceof String[]) {
      JSONArray array = new JSONArray();
      for (String arrValue : (String[]) value) {
        array.put(getJSONValue(arrValue));
      }
      return array;
    }
    return null;
  }
1149542
@SuppressWarnings("unchecked")
    private static Object getMappedValue(Object obj, Property property, Object key) {
        if (property == null) {
            throw new IllegalArgumentException("Cannot get the mapped value from a 'null' property.");
        }

        if (property.getType().isAssignableFrom(Map.class)) {
            Map<Object, Object> map = (Map<Object, Object>) property.get(obj);

            if (map == null) {
                throw new NullPointerException("Invalid 'null' value found for mapped " + property + " in "
                                                       + obj.getClass().getName() + ".");

            }

            return map.get(key);
        } else {
            throw new IllegalArgumentException("Cannot get a mapped value from the not mapped " + property
                                                       + ". Only Map type is supported, but " + property.getType().getSimpleName() + " found.");
        }
    }
96728
public static float getFloat(JsonObject object, String field) {
        final JsonValue value = object.get(field);
        throwExceptionIfNull(value, field);
        return value.asFloat();
    }
1242973
public static <T extends MPBase> JsonObject getJsonFromResource(T resourceObject) {
        return (JsonObject) gson.toJsonTree(resourceObject);
    }
1331768
public Object get(String key) throws JSONException {
    Object o = opt(key);
    if (o == null) {
      throw new JSONException("JSONObject[" + quote(key) + "] not found.");
    }
    return o;
  }
1169094
public JsonObject getJsonObject(int index) throws JsonException {
        JsonElement el = get(index);
        if (!el.isJsonObject()) {
            throw Util.typeMismatch(index, el, "JsonObject");
        }
        return el.asJsonObject();
    }
268969
@JsonValue
	public Object toJsonValue() {
		if (definition != null)
			return definition;
		if (reference != null)
			return reference;
		if (_null != null)
			return _null;
		return null;
	}
381215
protected String getJSONReply(final Object _jsonObject)
    {
        String ret = "";
        final ObjectMapper mapper = new ObjectMapper();
        if (LOG.isDebugEnabled()) {
            mapper.enable(SerializationFeature.INDENT_OUTPUT);
        }
        mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
        mapper.registerModule(new JodaModule());
        try {
            ret =  mapper.writeValueAsString(_jsonObject);
        } catch (final JsonProcessingException e) {
            LOG.error("Catched JsonProcessingException", e);
        }
        return ret;
    }
691090
@JsonValue
	public Object toJsonValue() {
		if (s != null)
			return s;
		if (n != null)
			return n;
		return null;
	}
1225690
public <T> JSONObject getJsonResponseFromGet(Class<T> objectClass,
												 Collection<? extends NameValuePair> params) throws RedmineException, JSONException {
		final List<NameValuePair> newParams = new ArrayList<>(params);
		List<NameValuePair> paramsList = new ArrayList<>(newParams);
		final URI uri = getURIConfigurator().getObjectsURI(objectClass, paramsList);
		final HttpGet http = new HttpGet(uri);
		final String response = send(http);
		final JSONObject responseObject = RedmineJSONParser.getResponse(response);
		return responseObject;
	}
1082475
public JSONObject getJSONObject(int index) throws JSONException {
		Object object = get(index);
		if (object instanceof JSONObject) {
			return (JSONObject) object;
		}
		else {
			throw JSON.typeMismatch(index, object, "JSONObject");
		}
	}
1330026
public static JSONObject beanToJson(Object object) throws IllegalAccessException, InvocationTargetException {
        Method[] methods = object.getClass().getMethods();
        JSONObject jsonObject = new JSONObject();
        for (Method method : methods) {
            String name = method.getName();
            if (name.startsWith("get") && !"getClass".equals(name)) {
                name = name.substring(3);
                jsonObject.put(name.substring(0, 1).toLowerCase() + name.substring(1), method.invoke(object));
            } else if (name.startsWith("is")) {
                jsonObject.put(name, method.invoke(object));
            }
        }
        return jsonObject;
    }
196402
public JSONObject getJsonObject(String endpoint) throws IOException {
        String res = this.get(endpoint, null, null);
        try {
            return new JSONObject(res);
        } catch (JSONException ex) {
            LOG.warn(res);
            throw ex;
        }
    }
333201
public static double getDouble(JsonObject object, String field) {
        final JsonValue value = object.get(field);
        throwExceptionIfNull(value, field);
        return value.asDouble();
    }
743720
def _fromJSON(cls, jsonobject):
        
        newInstance = cls(None, None)
        newInstance.__dict__.update(jsonobject)
        return newInstance
830895
public JsonObject getAsObject(String property) {
		if (!super.has(property)) {
			super.set(property, new JsonValue(new JsonObject()), false);
		}
		return get(property).getAsObject();
	}
550540
public Object get(String name) throws JSONException {
		Object result = this.nameValuePairs.get(name);
		if (result == null) {
			throw new JSONException("No value for " + name);
		}
		return result;
	}