吕展辉

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

从上一篇得到properties里的数据

1 Map<String,String> map = new HashMap<String,String>();
2 Enumeration<Object> keys = properties.keys();
3 while(keys.hasMoreElements()){
4     String key = (String)keys.nextElement();
5     String value = (String)properties.get(key);
6     map.put(key,value);
7 }

现在得到了properties里的数据,然后怎样转化为json?我用的是用Gson转化,看以下内容吧

1 Gson gson = new Gson();
2 String jsonStr = gson.toJson(map);
3 //以下是传输到调用页面
4 PrintWriter pw = response.getWriter(); 5 pw.print(jsonStr); 6 pw.flush();

 

posted on 2014-02-12 16:53  吕展辉  阅读(1762)  评论(0编辑  收藏  举报