Java Code Examples for com.alibaba.fastjson.JSONArray#toString()
The following examples show how to use
com.alibaba.fastjson.JSONArray#toString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JsonDBUtil.java From paraflow with Apache License 2.0 | 6 votes |
public static String rSetToJson(ResultSet rs) throws SQLException, JSONException { JSONArray array = new JSONArray(); ResultSetMetaData metaData = rs.getMetaData(); int columnCount = metaData.getColumnCount(); while (rs.next()) { JSONObject jsonObj = new JSONObject(); for (int i = 1; i <= columnCount; i++) { String columnName = metaData.getColumnLabel(i); String value = rs.getString(columnName); jsonObj.put(columnName, value); } array.add(jsonObj); } return array.toString(); }
Example 2
Source File: UserController.java From Tbed with GNU Affero General Public License v3.0 | 6 votes |
@RequestMapping("/login_c") @ResponseBody public String login( HttpSession httpSession, String Hellohao_UniqueUserKey) { JSONArray jsonArray = new JSONArray(); Integer ret = userService.login(null, null,Hellohao_UniqueUserKey); if (ret > 0) { User user = userService.getUsersMail(Hellohao_UniqueUserKey); if (user.getIsok() == 1) { httpSession.setAttribute("user", user); httpSession.setAttribute("email", user.getEmail()); jsonArray.add(1); } else if(ret==-1){ jsonArray.add(-1); }else { jsonArray.add(-2); } } else { jsonArray.add(0); } return jsonArray.toString(); }
Example 3
Source File: ClientController.java From Tbed with GNU Affero General Public License v3.0 | 6 votes |
@RequestMapping("/clientlogin") @ResponseBody public String login( HttpSession httpSession, String email, String password) { JSONArray jsonArray = new JSONArray(); String basepass = Base64Encryption.encryptBASE64(password.getBytes()); Integer ret = userService.login(email, basepass,null); if (ret > 0) { User user = userService.getUsers(email); if (user.getIsok() == 1) { jsonArray.add(1); } else if(ret==-1){ jsonArray.add(-1); }else { jsonArray.add(-2); } } else { jsonArray.add(0); } return jsonArray.toString(); }
Example 4
Source File: AdminController.java From Tbed with GNU Affero General Public License v3.0 | 6 votes |
@PostMapping("/change") @ResponseBody public String change(HttpSession session, User user) { User u = (User) session.getAttribute("user"); User us = new User(); us.setEmail(user.getEmail()); us.setUsername(user.getUsername()); us.setPassword(Base64Encryption.encryptBASE64(user.getPassword().getBytes())); us.setUid(u.getUid()); JSONArray jsonArray = new JSONArray(); Integer ret =0; if(u.getLevel()==1){ us.setUsername(null); us.setEmail(null); ret = userService.change(us); }else{ ret = userService.change(us); } jsonArray.add(ret); if (u.getEmail() != null && u.getPassword() != null) { session.removeAttribute("user"); session.invalidate(); } // -1 用户名重复 return jsonArray.toString(); }
Example 5
Source File: AdminRootController.java From Tbed with GNU Affero General Public License v3.0 | 5 votes |
@PostMapping("/setisok") @ResponseBody public String setisok(HttpSession session, User user) { JSONArray jsonArray = new JSONArray(); User u = (User) session.getAttribute("user"); if(u.getId()==user.getId()){ jsonArray.add(-2); }else{ Integer ret = userService.setisok(user); jsonArray.add(ret); } return jsonArray.toString(); }
Example 6
Source File: Res.java From android-project-wo2b with Apache License 2.0 | 5 votes |
/** * 返回列表数据, 反之返回空. * * @return */ public String getDataJSONArrayString() { JSONArray jsonArray = getDataJSONArray(); if (jsonArray != null) { return jsonArray.toString(); } return null; }
Example 7
Source File: ProtocolUtil.java From MicroCommunity with Apache License 2.0 | 5 votes |
/** * 创建报文体信息 * * @param objs * @return */ public static String createSvcCont(Object... objs) { JSONArray svcContArray = new JSONArray(); for (int objIndex = 0; objIndex < objs.length; objIndex++) { svcContArray.add(JSONObject.parseObject(JSONObject.toJSONString(objs[objIndex]))); } return svcContArray.toString(); }
Example 8
Source File: DictDataController.java From LuckyFrameWeb with GNU Affero General Public License v3.0 | 5 votes |
/** * Ajax前台获取操作字典 * @param stepType 步骤类型 * @return 返回步骤类型集合 * @author Seagull * @date 2019年3月12日 */ @GetMapping("/getDictDataListByStepType/{stepType}") @ResponseBody public String getDictDataListByStepType(@PathVariable("stepType") Integer stepType) { String str = "{\"message\": \"\",\"value\": ,\"code\": 200,\"redirect\": \"\" }"; try { JSONObject json; DictData dictData=new DictData(); if(stepType==0){ dictData.setDictType("testmanagmt_casestep_httpoperation"); }else if(stepType==1){ dictData.setDictType("testmanagmt_casestep_uioperation"); }else if(stepType==3){ dictData.setDictType("testmanagmt_casestep_muioperation"); }else{ dictData.setDictType("9999999999999999999999999999999999"); } List<DictData> ddlist = dictDataService.selectDictDataList(dictData); JSONArray jsonarr = new JSONArray(); for(DictData obdd:ddlist){ JSONObject jo = new JSONObject(); jo.put("name", obdd.getDictValue()); jo.put("description", obdd.getRemark()); jsonarr.add(jo); } String recordJson = jsonarr.toString(); json = JSONObject.parseObject("{\"message\": \"\",\"value\": "+recordJson+",\"code\": 200,\"redirect\": \"\" }"); str=json.toString(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return str; }
Example 9
Source File: ProjectProtocolTemplateController.java From LuckyFrameWeb with GNU Affero General Public License v3.0 | 5 votes |
/** * Ajax前台获取协议模板列表 * @param projectId 项目ID * @author Seagull * @date 2019年3月12日 */ @GetMapping("/getTemplateListByProjectId/{projectId}") @ResponseBody public String getTemplateListByProjectId(@PathVariable("projectId") Integer projectId) { String str = "{\"message\": \"\",\"value\": ,\"code\": 200,\"redirect\": \"\" }"; try { JSONObject json; ProjectProtocolTemplate projectProtocolTemplate=new ProjectProtocolTemplate(); projectProtocolTemplate.setProjectId(projectId); List<ProjectProtocolTemplate> ptlist = projectProtocolTemplateService.selectProjectProtocolTemplateList(projectProtocolTemplate); JSONArray jsonarr = new JSONArray(); for(ProjectProtocolTemplate obppt:ptlist){ JSONObject jo = new JSONObject(); jo.put("templateName", "【"+obppt.getTemplateId()+"】"+obppt.getTemplateName()); jo.put("updateBy", obppt.getUpdateBy()); jo.put("updateTime", DateUtils.parseDateToStr("yy-MM-dd HH:mm:ss", obppt.getUpdateTime())); jsonarr.add(jo); } String recordJson = jsonarr.toString(); json = JSONObject.parseObject("{\"message\": \"\",\"value\": "+recordJson+",\"code\": 200,\"redirect\": \"\" }"); str=json.toString(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return str; }
Example 10
Source File: DatabaseConnectController.java From incubator-iotdb with Apache License 2.0 | 5 votes |
/** * convert query result data to JSON format. * * @param request http request * @param response http response * @return data in JSON format */ @RequestMapping(value = "/query") @ResponseBody public String query(HttpServletRequest request, HttpServletResponse response) { String targetStr = "target"; response.setStatus(200); try { JSONObject jsonObject = getRequestBodyJson(request); Pair<ZonedDateTime, ZonedDateTime> timeRange = getTimeFromAndTo(jsonObject); JSONArray array = (JSONArray) jsonObject.get("targets"); // [] JSONArray result = new JSONArray(); for (int i = 0; i < array.size(); i++) { JSONObject object = (JSONObject) array.get(i); // {} if (!object.containsKey(targetStr)) { return "[]"; } String target = (String) object.get(targetStr); String type = getJsonType(jsonObject); JSONObject obj = new JSONObject(); obj.put("target", target); if (type.equals("table")) { setJsonTable(obj, target, timeRange); } else if (type.equals("timeserie")) { setJsonTimeseries(obj, target, timeRange); } result.add(i, obj); } logger.info("query finished"); return result.toString(); } catch (Exception e) { logger.error("/query failed", e); } return null; }
Example 11
Source File: UpdateImgController.java From Tbed with GNU Affero General Public License v3.0 | 5 votes |
@RequestMapping("/sentence") @ResponseBody public String sentence(HttpSession session, Integer id) { JSONArray jsonArray = new JSONArray(); String text = Sentence.getURLContent(); jsonArray.add(text); return jsonArray.toString(); }
Example 12
Source File: AdminRootController.java From Tbed with GNU Affero General Public License v3.0 | 5 votes |
@PostMapping("/setmemory") @ResponseBody public String setmemory(HttpSession session, User user) { Integer ret = userService.setmemory(user); JSONArray jsonArray = new JSONArray(); jsonArray.add(ret); return jsonArray.toString(); }
Example 13
Source File: DesignElementService.java From mPaaS with Apache License 2.0 | 5 votes |
/** 查询摘要信息,并转换成String */ private String listToString(List<Object[]> list) { JSONArray array = new JSONArray(); for (Object[] summary : list) { JSONObject json = new JSONObject(); json.put(PROP_ID, summary[0]); json.put(PROP_LABEL, summary[1]); json.put(PROP_MD5, summary[2]); json.put(PROP_MESSAGEKEY, summary[3]); json.put(PROP_MODULE, summary[4]); array.add(json); } return array.toString(); }
Example 14
Source File: AdminRootController.java From Tbed with GNU Affero General Public License v3.0 | 5 votes |
@PostMapping("/deleuser") @ResponseBody public String deleuser(HttpSession session, Integer id) { JSONArray jsonArray = new JSONArray(); User u = (User) session.getAttribute("user"); if(u.getId()==id){ jsonArray.add("-1"); }else{ Integer ret = userService.deleuser(id); jsonArray.add(ret); } return jsonArray.toString(); }
Example 15
Source File: AdminRootController.java From Tbed with GNU Affero General Public License v3.0 | 5 votes |
@PostMapping("/updatekey") @ResponseBody public String updatekey(Keys key) { JSONArray jsonArray = new JSONArray(); Config config = new Config(); config.setSourcekey(key.getStorageType()); Integer val = configService.setSourceype(config); Integer ret = -2; //修改完初始化 if(key.getStorageType()==1){ ret =nOSImageupload.Initialize(key);//实例化网易 }else if (key.getStorageType()==2){ ret = OSSImageupload.Initialize(key); }else if(key.getStorageType()==3 || key.getStorageType()==8){ ret = USSImageupload.Initialize(key); }else if(key.getStorageType()==4){ ret = KODOImageupload.Initialize(key); }else if(key.getStorageType()==6){ ret = COSImageupload.Initialize(key); }else if(key.getStorageType()==7){ ret = FTPImageupload.Initialize(key); } else{ Print.Normal("为获取到存储参数,或者使用存储源是本地的。"); } if(ret>0){ ret = keysService.updateKey(key); } //-1 对象存储有参数为空,初始化失败 //0,保存失败 //1 正确 jsonArray.add(ret); return jsonArray.toString(); }
Example 16
Source File: AdminRootController.java From Tbed with GNU Affero General Public License v3.0 | 5 votes |
@PostMapping("/getkey") @ResponseBody public String getkey(Integer storageType) { JSONArray jsonArray = new JSONArray(); Keys key = keysService.selectKeys(storageType); jsonArray.add(key); return jsonArray.toString(); }
Example 17
Source File: UserController.java From Tbed with GNU Affero General Public License v3.0 | 5 votes |
@RequestMapping("/login") @ResponseBody public String login( HttpServletResponse response,HttpSession httpSession, String email, String password,Integer logotmp) { JSONArray jsonArray = new JSONArray(); if((logotmp-number1)==(istmp1-number1)){ String basepass = Base64Encryption.encryptBASE64(password.getBytes()); Integer ret = userService.login(email, basepass,null); if (ret > 0) { User user = userService.getUsers(email); if (user.getIsok() == 1) { httpSession.setAttribute("user", user); httpSession.setAttribute("email", user.getEmail()); Cookie cookie = new Cookie("Hellohao_UniqueUserKey", userService.getUsers(user.getEmail()).getUid()); cookie.setMaxAge(60*60*24*90); cookie.setPath("/"); response.addCookie(cookie); jsonArray.add(1); } else if(ret==-1){ jsonArray.add(-1); }else { jsonArray.add(-2); } } else { jsonArray.add(0); } }else{jsonArray.add(-3);//非法登录 } return jsonArray.toString(); }
Example 18
Source File: GroupController.java From Tbed with GNU Affero General Public License v3.0 | 5 votes |
@PostMapping("/getgrouplist") @ResponseBody public String getgrouplist() { List<Group> li = groupService.grouplist(); JSONArray jsonArray = new JSONArray(); for (Group group : li) { jsonArray.add(group); } return jsonArray.toString(); }
Example 19
Source File: QaAccidentController.java From LuckyFrameWeb with GNU Affero General Public License v3.0 | 4 votes |
/** * 图形展示生产事故异步加载数据 * @param request 请求 * @return 拉取数据 */ @ResponseBody @GetMapping("/getGraphData") public String getGraphData(HttpServletRequest request) { String projectId = request.getParameter("projectId"); String queryStartDate = request.getParameter("queryStartDate"); String queryEndDate = request.getParameter("queryEndDate"); String statistical = request.getParameter("Statistical"); String dataLatitude = request.getParameter("dataLatitude"); QaAccident qaAccident = new QaAccident(); if(StringUtils.isNotEmpty(projectId)){ qaAccident.setProjectId(Integer.valueOf(projectId)); } Map<String, Object> params = new HashMap<>(); params.put("beginTime", queryStartDate); params.put("endTime", queryEndDate); qaAccident.setParams(params); /*数据统计纬度*/ if("1".equals(dataLatitude)){ qaAccident.setImpactTime(0); }else if("2".equals(dataLatitude)){ qaAccident.setDurationTime(0); }else{ qaAccident.setAccidentType("true"); } List<Map<Object, Object>> list; /*事故类型或是等级纬度*/ if("0".equals(statistical)){ list=qaAccidentService.selectGroupByAccidentType(qaAccident); }else{ list=qaAccidentService.selectGroupByAccidentLevel(qaAccident); } PieCharts[] arraydata = new PieCharts[list.size()]; String[] legendData=new String[list.size()]; for(int i=0;i<list.size();i++){ Map<Object, Object> map=list.get(i); PieCharts pieData=new PieCharts(); pieData.setName(map.get("selectName").toString()); pieData.setValue(Double.parseDouble(map.get("selectValue").toString())); arraydata[i] = pieData; legendData[i] = map.get("selectName").toString(); } String titleText="事故分析饼图"; String titleSubText="所有项目"; JSONArray jsonArrayData = (JSONArray)JSONArray.toJSON(arraydata); JSONArray jsonArraylegendData = (JSONArray)JSONArray.toJSON(legendData); return "{\"seriesData\":"+jsonArrayData.toString()+",\"legendData\":"+jsonArraylegendData.toString()+",\"titleText\":\""+titleText+"\",\"titleSubText\":\""+titleSubText+"\"}"; }