code: public static <T> JSONArray listToJSONArray(final List<T> list) {
          final JSONArray ret = new JSONArray();
  
          if (null == list) {
              return ret;
          }
  
          for (final T object : list) {
              ret.put(object);
          }
  
          return ret;
      }
docs: Converts the specified {@link List list} to a
  {@link JSONArray JSON array}.
  
  @param <T>  the type of elements maintained by the specified list
  @param list the specified list
  @return a {@link JSONArray JSON array}