StringBuilder stringBuilder = new StringBuilder("[");
String ssString;
ArrayList<CompetitionsByCity> ccs =competitionMapper.getCmptList(hashMap); for (CompetitionsByCity tmp:ccs)
{ stringBuilder.append("{\"cmptId\":"+"\""+tmp.getCmptId()+"\""+","+"\"cmptName\":"+"\""+tmp.getCmptName()+"\""+","+
"\"duration\":"+"\""+tmp.getDuration()+"\""+","+"\"cmptStarLevel\":"+"\""+tmp.getCmptStarLevel()+"\""+","+"\"cmptCapacity\":"+"\""+tmp.getCmptCapacity()+"\""+","+"\"cmptLength\":"+"\""+tmp.getCmptLength()+"\""+
"\"cmptFavorByMe\":"+"\""+"0"+"\""+","+"\"imgId\":"+"\""+tmp.getImgId()+"\""+"},"); //stringBuilder.append(stringBuilder); }

下面是使用Gson

 String ssString;
ArrayList<CompetitionsByCity> ccs = competitionMapper
.getCmptList(hashMap);
Gson gson = new Gson();
String str = gson.toJson(ccs);
ssString = "\"size\":" + ccs.size() + "," + "\"cmptList\":" + str;
return ssString;

最新文章

  1. Servlet下载文件和http响应
  2. ubuntu下mysql的常用命令,MySQL数据库的基本操作命令
  3. 常用sql,在做项目时用mysqlWorkBeach里面自动生成的
  4. #define x do{......} while(0)的用处
  5. zzzzw_在线考试系统③完结篇
  6. Tomcat基础教程(二)
  7. Shell脚本常用命令简介
  8. 基于visual Studio2013解决C语言竞赛题之0401阶乘
  9. Oracle 11g client安装和配置。
  10. 使用js在新窗口中POST数据
  11. python3实现TCP协议的简单服务器和客户端
  12. 关于JS中获取浏览器高度和宽度值的多种方法(多浏览器)
  13. Typora使用说明(记录总结)
  14. 大端&amp;小端问题
  15. How to distinguish between strings in heap or literals?
  16. ABC3
  17. Java Base64 编码解码方案总结
  18. 构造函数 (C++)
  19. 2018.09.16 loj#10243. 移棋子游戏(博弈论)
  20. Windows 上 GitHub Desktop 的操作[转]

热门文章

  1. 用C#实现生成PDF文档
  2. google自定义站内搜索
  3. var_dump(php)
  4. Java学习笔记---继承和super的用法
  5. VS2010中xercesc配置及简单示例
  6. js清空页面控件值
  7. google base 之MessagePumpForUI
  8. 常用Python第三方库 简介
  9. Yaf-Plus 我们只谈框架这件事
  10. TCPL 行计数