Code example for Field

Methods: getModifiers, isSynthetic

0
		String objectPackageName = objectPackage != null ? objectPackage.getName() : "";
		return objectPackageName.startsWith("java.") || objectPackageName.startsWith("javax.") || cls.getClassLoader() == null;
	} 
 
	static boolean IsJSONPrintable(Field field) {
		return !field.isSynthetic() && !Modifier.isStatic(field.getModifiers()) && !Modifier.isTransient(field.getModifiers());
	} 
 
	public @CheckForNull 
	Object toJSON(@CheckForNull Object from, boolean allowEmpty) throws JSONException {
 
		if (from == null || Void.class.isAssignableFrom(from.getClass()))
			return null; 
 
		Class<?> fromClass = from.getClass();
 
		if (from instanceof JSONObject || from instanceof JSONArray || JSONObject.NULL.equals(from) || from instanceof Byte || from instanceof Character || from instanceof Short || from instanceof Integer || from instanceof Long || from instanceof Boolean || from instanceof Float || from instanceof Double || from instanceof String) {
			return from;
		} 
 
		if (Collection.class.isAssignableFrom(fromClass)) {