Java Code Examples for com.alibaba.fastjson.JSONArray#parseObject()
The following examples show how to use
com.alibaba.fastjson.JSONArray#parseObject() .
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: ProjectInvolveManager.java From Cynthia with GNU General Public License v2.0 | 6 votes |
/** * @Title: getProjectNameById * @Description: 根据项目Id查询项目名字 * @param productId * @return * @return: String */ public String getProjectNameById(String projectId){ String projectName = proNameMap.get(projectId); String result = ""; if (proNameMap.get(projectName) == null) { if (isProjectInvolved()) { String cookie = getUserSign("", "1"); // 1为管理员用户 try { String getUrl = String.format(properties.getProperty("base_url") + properties.getProperty("project_name_get_url"), projectId); result = URLUtil.sendGet(getUrl, "",cookie); JSONObject jsonObject = JSONArray.parseObject(result); if (jsonObject != null) { projectName = jsonObject.getString("name"); if (projectName != null) { proNameMap.put(projectId, projectName); } } } catch (Exception e) { System.out.println("getProjectNameById error! projectId:" + projectId + " and result is : " + result); } } } return projectName; }
Example 2
Source File: ProjectInvolveManager.java From Cynthia with GNU General Public License v2.0 | 6 votes |
/** * @Title: getProductNameById * @Description: 根据产品Id查询产品名字 * @param productId * @return * @return: String */ public String getProductNameById(String productId){ String productName = proNameMap.get(productId); if (proNameMap.get(productId) == null) { if (isProjectInvolved()) { String cookie = getUserSign("", "1"); try { String getUrl = String.format(properties.getProperty("base_url") + properties.getProperty("product_name_get_url"), productId); String result = URLUtil.sendGet(getUrl, "",cookie); JSONObject jsonObject = JSONArray.parseObject(result); if (jsonObject != null) { productName = jsonObject.getString("name"); if (productName != null) { proNameMap.put(productId, productName); } } } catch (Exception e) { e.printStackTrace(); } } } return productName; }
Example 3
Source File: WecubeAdapterController.java From we-cmdb with Apache License 2.0 | 5 votes |
private OperateCiJsonResponse getCiDataResponse(StringBuffer url, Map<String, Object> stringObjectMap) { OperateCiJsonResponse response = new OperateCiJsonResponse(); try { String results = HttpUtils.post(stringObjectMap, url.toString()); List<Map<String, Object>> listObjectSec = JSONArray.parseObject(results, List.class); response = OperateCiJsonResponse.okayWithData(listObjectSec); } catch (IOException e) { response = OperateCiJsonResponse.errorWithData(e.getMessage(), null); } return response; }
Example 4
Source File: ProjectInvolveManager.java From Cynthia with GNU General Public License v2.0 | 5 votes |
/** * @Title: getUserInfoByMail * @Description: 获取用户信息 * @return * @return: List<UserInfo> */ public UserInfo getUserInfoById(String userId){ UserInfo userInfo = null; if (userId == null) { return null; } if (userId.indexOf(".") != -1) { userId = userId.split("\\.")[0]; } String cookie = getUserSign("",userId); if (CynthiaUtil.isNull(userId)) { return userInfo; } if (isProjectInvolved()) { try { String getUrl = String.format(properties.getProperty("base_url") + properties.getProperty("user_get_by_id_url"), userId); String result = URLUtil.sendGet(getUrl, "",cookie); JSONObject jsonObject = JSONArray.parseObject(result); userInfo = new UserInfoImpl(); userInfo.setId(Integer.parseInt(jsonObject.getString("id"))); userInfo.setUserName(jsonObject.getString("email")); userInfo.setNickName(jsonObject.getString("name")); userInfo.setCreateTime(Timestamp.valueOf(jsonObject.getString("updateTime").replace("T", " ").replace("Z", ""))); userInfo.setUserRole(priviledgeQuery(userId, "cynthia_entryConfig") ? UserRole.admin : UserRole.normal); userInfo.setPicUrl("http://www.effevo.com/anonymous/resource/user/logo/" + userInfo.getId()+ "/large"); userNameMap.put(userInfo.getUserName(), userInfo.getNickName()); } catch (Exception e) { e.printStackTrace(); } } return userInfo; }
Example 5
Source File: ProjectInvolveManager.java From Cynthia with GNU General Public License v2.0 | 5 votes |
/** * @Title: getUserInfoByMail * @Description: 获取用户信息 * @return * @return: List<UserInfo> */ public UserInfo getUserInfoByMail(String userMail){ UserInfo userInfo = null; if (CynthiaUtil.isNull(userMail)) { return userInfo; } String cookie = getUserSign(userMail,""); if (isProjectInvolved()) { try { String getUrl = String.format(properties.getProperty("base_url") + properties.getProperty("user_get_by_mail_url"), userMail); System.out.println("getUserInfoByMail,url:" + getUrl); String result = URLUtil.sendGet(getUrl, "",cookie); JSONObject jsonObject = JSONArray.parseObject(result); userInfo = new UserInfoImpl(); userInfo.setId(Integer.parseInt(jsonObject.getString("id"))); userInfo.setUserName(jsonObject.getString("email")); userInfo.setNickName(jsonObject.getString("name")); userInfo.setCreateTime(Timestamp.valueOf(jsonObject.getString("updateTime").replace("T", " ").replace("Z", ""))); userInfo.setUserStat(UserStat.normal); userInfo.setUserRole(priviledgeQuery(String.valueOf(userInfo.getId()), "cynthia_entryConfig") ? UserRole.admin : UserRole.normal); userInfo.setPicUrl("http://www.effevo.com/resource/user/logo/" + userInfo.getId()+ "/large"); userNameMap.put(userInfo.getUserName(), userInfo.getNickName()); } catch (Exception e) { System.out.println("error in getUserInfoByMail , userMail :" + userMail); } } return userInfo; }
Example 6
Source File: BackRightController.java From Cynthia with GNU General Public License v2.0 | 3 votes |
/** * * @Title:getSystem * @Type:BackRightController * @description:return the system setting(json string) * @date:2014-5-5 下午8:06:06 * @version:v1.0 * @param userMail * @param request * @param httpSession * @return * @throws Exception */ @ResponseBody @RequestMapping("/getSystem.do") public String getSystem(@RequestParam("userMail") String userMail ,HttpServletRequest request, HttpSession httpSession) throws Exception { JSONObject jsonObject = JSONArray.parseObject(das.getSystemOption(userMail)); Map<String, Object> sysMap = new HashMap<String, Object>(); for (String key : jsonObject.keySet()) { sysMap.put(key, jsonObject.get(key)); } sysMap.put("projectInvolved", String.valueOf(ProjectInvolveManager.getInstance().isProjectInvolved())); return JSONArray.toJSONString(sysMap); }