/**
* 返回两个JsonArray的合并后的字符串
* @param mData
* @param array
* @return
*/
public static String joinJSONArray(JSONArray mData, JSONArray array) {
StringBuffer buffer = new StringBuffer();
try {
int len = mData.size();
for (int i = 0; i < len; i++) {
JSONObject obj1 = (JSONObject) mData.get(i);
if (i == len - 1)
buffer.append(obj1.toString());
else
buffer.append(obj1.toString()).append(",");
}
len = array.size();
if (len > 0)
buffer.append(",");
for (int i = 0; i < len; i++) {
JSONObject obj1 = (JSONObject) array.get(i);
if (i == len - 1)
buffer.append(obj1.toString());
else
buffer.append(obj1.toString()).append(",");
}
// buffer.insert(0, "[").append("]");
return buffer.toString();
} catch (Exception e) {
}
return null;
}
Java中将两个jsonarray合并为一个字符串输出
最新推荐文章于 2024-08-17 04:03:10 发布