serialize a List (as Array)

@param list List to serialize
@param done
@return serialized list
@throws ConverterException
174469
private String _serializeList(List list, Map<Object, String> done, String id) throws ConverterException {
	// <ARRAY ID="1" SIZE="1"><ITEM INDEX="1" TYPE="STRING">hello world</ITEM></ARRAY>
	StringBuilder sb = new StringBuilder(goIn() + "<ARRAY ID=\"" + id + "\" SIZE=" + del + list.size() + del + ">");
	int index;
	ListIterator it = list.listIterator();
	while (it.hasNext()) {
	    // <ITEM INDEX="1" TYPE="STRING">hello world</ITEM>
	    index = it.nextIndex();
	    String value = _serialize(it.next(), done);
	    sb.append(goIn() + "<ITEM INDEX=\"" + (index + 1) + "\" TYPE=\"" + type + "\">");
	    sb.append(value);
	    sb.append(goIn() + "</ITEM>");
	}

	sb.append(goIn() + "</ARRAY>");
	type = "ARRAY";
	return sb.toString();
    }
448117
private String _serializeQuery(Query query, Map<Object, String> done, String id) throws ConverterException {

	/*
	 * <QUERY ID="1"> <COLUMNNAMES> <COLUMN NAME="a"></COLUMN> <COLUMN NAME="b"></COLUMN> </COLUMNNAMES>
	 * 
	 * <ROWS> <ROW> <COLUMN TYPE="STRING">a1</COLUMN> <COLUMN TYPE="STRING">b1</COLUMN> </ROW> <ROW>
	 * <COLUMN TYPE="STRING">a2</COLUMN> <COLUMN TYPE="STRING">b2</COLUMN> </ROW> </ROWS> </QUERY>
	 */
	Collection.Key[] keys = CollectionUtil.keys(query);
	StringBuilder sb = new StringBuilder(goIn() + "<QUERY ID=\"" + id + "\">");

	// columns
	sb.append(goIn() + "<COLUMNNAMES>");
	for (int i = 0; i < keys.length; i++) {
	    sb.append(goIn() + "<COLUMN NAME=\"" + keys[i].getString() + "\"></COLUMN>");
	}
	sb.append(goIn() + "</COLUMNNAMES>");

	String value;
	deep++;
	sb.append(goIn() + "<ROWS>");
	int len = query.getRecordcount();
	for (int row = 1; row <= len; row++) {
	    sb.append(goIn() + "<ROW>");
	    for (int col = 0; col < keys.length; col++) {
		try {
		    value = _serialize(query.getAt(keys[col], row), done);
		}
		catch (PageException e) {
		    value = _serialize(e.getMessage(), done);
		}
		sb.append("<COLUMN TYPE=\"" + type + "\">" + value + "</COLUMN>");
	    }
	    sb.append(goIn() + "</ROW>");

	}
	sb.append(goIn() + "</ROWS>");
	deep--;

	sb.append(goIn() + "</QUERY>");
	type = "QUERY";
	return sb.toString();
    }
245905
protected <T> List<T> toArrayList(List<T> list) {
        if (list == null) {
            return null;
        }
        if (!list.getClass().equals(ArrayList.class)) {
            list = new ArrayList<>(list);
        }
        return list;
    }
1084570
public static <T> List<T> toList(TypedIterable<T> iterable) {
        List<T> result = new ArrayList<>();
        for (T item : iterable) {
            result.add(item);
        }
        return result;
    }
269865
protected <T> List<? extends List<T>> toArrayLists(List<List<T>> lists) {
        for (int i = 0; i < lists.size(); i++) {
            List<T> list = lists.get(i);
            lists.set(i, toArrayList(list));
        }
        return lists;
    }
667824
public void _serializeStruct(Struct struct, StringBuilder sb, Set<Object> done) throws ConverterException {
	sb.append(goIn());
	sb.append('{');
	Iterator it = struct.keyIterator();
	boolean doIt = false;
	deep++;
	while (it.hasNext()) {
	    String key = Caster.toString(it.next(), "");
	    if (doIt) sb.append(',');
	    doIt = true;
	    sb.append(QUOTE_CHR);
	    sb.append(escape(key));
	    sb.append(QUOTE_CHR);
	    sb.append(':');
	    _serialize(struct.get(key, null), sb, done);
	}
	deep--;

	sb.append('}');
    }
1000055
def serialize_list(self, tag):
        """"""
        separator, fmt = self.comma, '[{}]'

        with self.depth():
            if self.should_expand(tag):
                separator, fmt = self.expand(separator, fmt)

            return fmt.format(separator.join(map(self.serialize, tag)))
914408
public static <T, J extends Convertable<T>> ArrayList<T> convert(J[] array) {
        return convert(array == null ? null : Arrays.asList(array));
    }
456518
private void _serializeMap(Map map, StringBuilder sb, Set<Object> done) throws ConverterException {
	if (map instanceof Serializable) {
	    _serializeSerializable((Serializable) map, sb);
	    return;
	}
	sb.append(goIn());
	sb.append("{");

	Iterator it = map.keySet().iterator();
	boolean doIt = false;
	deep++;
	while (it.hasNext()) {
	    Object key = it.next();
	    if (doIt) sb.append(',');
	    doIt = true;
	    sb.append(QUOTE_CHR);
	    sb.append(escape(key.toString()));
	    sb.append(QUOTE_CHR);
	    sb.append(':');
	    _serialize(map.get(key), sb, done);
	}
	deep--;

	sb.append('}');
    }
1057189
def _serialize_list(cls, list_):
        

        list_serialized = []

        for item in list_:
            item_serialized = cls.serialize(item)
            list_serialized.append(item_serialized)

        return list_serialized
882682
static public String listToJSONString(List<?> list) {
		if (list == null || list.size() == 0) {
			return "[]";
		}
		StringBuilder sb = new StringBuilder("[");
		for (Object o : list) {
			buildAppendString(sb, o).append(',').append(' ');
		}
		return sb.delete(sb.length() - 2, sb.length()).append(']').toString();
	}
1349278
private static function encodeList($list, &$serialized)
    {
        if (empty($list)) {
            $serialized .= "le";
            return;
        }

        $serialized .= "l";
        for ($i = 0; isset($list[$i]); $i++) {
            self::decideEncode($list[$i], $serialized);
        }
        $serialized .= "e";
    }
82278
private String _serializeArray(Array array, Set<Object> done) throws ConverterException {
	return _serializeList(array.toList(), done);
    }
436450
private void _serializeQuery(Query query, StringBuilder sb, Set<Object> done) throws ConverterException {

	// Collection.Key[] keys = query.keys();
	Iterator<Key> it = query.keyIterator();
	Key k;
	sb.append(goIn());
	sb.append("query(");

	deep++;
	boolean oDoIt = false;
	int len = query.getRecordcount();
	while (it.hasNext()) {
	    k = it.next();
	    if (oDoIt) sb.append(',');
	    oDoIt = true;
	    sb.append(goIn());
	    sb.append(QUOTE_CHR);
	    sb.append(escape(k.getString()));
	    sb.append(QUOTE_CHR);
	    sb.append(":[");
	    boolean doIt = false;
	    for (int y = 1; y <= len; y++) {
		if (doIt) sb.append(',');
		doIt = true;
		try {
		    _serialize(query.getAt(k, y), sb, done);
		}
		catch (PageException e) {
		    _serialize(e.getMessage(), sb, done);
		}
	    }
	    sb.append(']');
	}
	deep--;

	sb.append(')');

    }
1072621
public static <T, J extends Convertable<T>> ArrayList<T> convert(Collection<J> collection) {
        if (collection == null) {
            return null;
        }

        ArrayList<T> list = new ArrayList<>(collection.size());

        for (J json : collection) {
            try {
                T item = json == null ? null : json.convert();
                if (item != null) {
                    list.add(item);
                }
            } catch (ParseException e) {
                Log.e("ConvertUtils", "Error converting item (" + json.getClass().getSimpleName()
                        + ") : " + e.getMessage());
            }
        }

        return list;
    }
224677
public static <T> List<T> copy(final List<T> list) {
		if (list == null) {
			return null;
		}

		TypeEnum elementType = null;
		List<T> copy = new ArrayList<T>();
		for (T element : list) {
			T elementCopy = null;
			if (element != null) {
				if (elementType == null) {
					elementType = TypeEnum.dataTypeOf(element.getClass());
				}
				elementCopy = copy(element, elementType);
			}

			copy.add(elementCopy);
		}

		return copy;
	}
1003495
private void _serializeArray(Array array, StringBuilder sb, Set<Object> done) throws ConverterException {
	_serializeList(array.toList(), sb, done);
    }