Java Code Examples for com.alibaba.fastjson.JSONObject#clear()
The following examples show how to use
com.alibaba.fastjson.JSONObject#clear() .
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: CommonUtil.java From SpringBoot-Shiro-Vue-master-20180625 with Apache License 2.0 | 6 votes |
/** * 验证是否含有全部必填字段 * * @param requiredColumns 必填的参数字段名称 逗号隔开 比如"userId,name,telephone" * @param jsonObject * @return */ public static void hasAllRequired(final JSONObject jsonObject, String requiredColumns) { if (!StringTools.isNullOrEmpty(requiredColumns)) { //验证字段非空 String[] columns = requiredColumns.split(","); String missCol = ""; for (String column : columns) { Object val = jsonObject.get(column.trim()); if (StringTools.isNullOrEmpty(val)) { missCol += column + " "; } } if (!StringTools.isNullOrEmpty(missCol)) { jsonObject.clear(); jsonObject.put("returnCode", ErrorEnum.E_90003.getErrorCode()); jsonObject.put("returnMsg", "缺少必填参数:" + missCol.trim()); jsonObject.put("returnData", new JSONObject()); throw new CommonJsonException(jsonObject); } } }
Example 2
Source File: CommonUtil.java From SpringBoot-Shiro-Vue with MIT License | 6 votes |
/** * 验证是否含有全部必填字段 * * @param requiredColumns 必填的参数字段名称 逗号隔开 比如"userId,name,telephone" */ public static void hasAllRequired(final JSONObject jsonObject, String requiredColumns) { if (!StringTools.isNullOrEmpty(requiredColumns)) { //验证字段非空 String[] columns = requiredColumns.split(","); String missCol = ""; for (String column : columns) { Object val = jsonObject.get(column.trim()); if (StringTools.isNullOrEmpty(val)) { missCol += column + " "; } } if (!StringTools.isNullOrEmpty(missCol)) { jsonObject.clear(); jsonObject.put("code", ErrorEnum.E_90003.getErrorCode()); jsonObject.put("msg", "缺少必填参数:" + missCol.trim()); jsonObject.put("info", new JSONObject()); throw new CommonJsonException(jsonObject); } } }
Example 3
Source File: TagUtil.java From jeecg with Apache License 2.0 | 5 votes |
/** * 控件类型:easyui * 返回datagrid JSON数据 * @param response * @param dataGrid * @param extMap 数据列表的扩展 */ public static void datagrid(HttpServletResponse response,DataGrid dg,Map<String,Map<String,Object>> extMap) { response.setContentType("application/json"); response.setHeader("Cache-Control", "no-store"); String jsonStr = TagUtil.getJson(dg); JSONObject object = JSONObject.parseObject(jsonStr); JSONArray r = object.getJSONArray("rows"); for (Object object2 : r) { JSONObject o =(JSONObject) object2; o.putAll(extMap.get(o.get("id"))); } try { PrintWriter pw = response.getWriter(); pw = response.getWriter(); pw.write(object.toString()); pw.flush(); pw.close(); } catch (IOException e) { e.printStackTrace(); }finally{ try { object.clear(); dg.clear(); jsonStr = null; dg = null; extMap = null; } catch (Exception e2) { // TODO: handle exception } } }