docs: 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;
    }