Here you can find the source of transformToJsonArray(List> objectsWithJsonToString)
public static String transformToJsonArray(List<?> objectsWithJsonToString)
//package com.java2s; //License from project: Apache License import java.util.List; public class Main { /**/*www. j a va2 s . c o m*/ * Object.toString() has to return json */ public static String transformToJsonArray(List<?> objectsWithJsonToString) { StringBuilder json = new StringBuilder("["); for (Object object : objectsWithJsonToString) { json.append(object.toString()).append(","); } if (objectsWithJsonToString.size() > 0 && json.charAt(json.length() - 1) == ',') { json = new StringBuilder(json.substring(0, json.length() - 1)); } json.append("]"); return json.toString(); } }