Java Code Examples for com.alibaba.fastjson.JSONObject#toJSONString()

The following examples show how to use com.alibaba.fastjson.JSONObject#toJSONString() . These examples are extracted from open source projects. 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 Project: jeewx-api   File: JwMenuAPI.java    License: Apache License 2.0 6 votes vote down vote up
/** 
 * 创建应用菜单
 * @param menu 菜单实例 
 * 		button	是	一级菜单数组,个数应为1~3个
 * 		sub_button	否	二级菜单数组,个数应为1~5个
 * 		type	是	菜单的响应动作类型
 * 		name	是	菜单标题,不超过16个字节,子菜单不超过40个字节
 * 		key	click等点击类型必须	菜单KEY值,用于消息接口推送,不超过128字节
 * 		url	view类型必须	网页链接,用户点击菜单可打开链接,不超过256字节
 * @param accessToken 有效的access_token 
 * @param agentid  企业应用的id,整型,可在应用的设置页面查看
 * @return 0表示成功,其他值表示失败 
 */  
public static int createMenu(Menu menu, String accessToken,String agentid) {  
	logger.info("[CREATEMENU]", "createMenu param:accessToken:{},agentid:{},menu:{}", new Object[]{accessToken,agentid,menu});
    int result = 0;  
    // 拼装创建菜单的url  
    String url = menu_create_url.replace("ACCESS_TOKEN", accessToken).replace("AGENTID", agentid);  
    // 将菜单对象转换成json字符串  
    String jsonMenu = JSONObject.toJSONString(menu);  
    logger.info("[CREATEMENU]", "createMenu param:jsonMenu:{}", new Object[]{jsonMenu});
    // 调用接口创建菜单  
    JSONObject jsonObject = HttpUtil.sendPost(url, jsonMenu);  
    logger.info("[CREATEMENU]", "createMenu response:{}", new Object[]{jsonObject.toJSONString()});
    if (null != jsonObject) {  
    	int errcode = jsonObject.getIntValue("errcode");
        result = errcode;
    }  
    return result;  
}
 
Example 2
Source Project: JobX   File: AbstractSendNotice.java    License: Apache License 2.0 6 votes vote down vote up
public String getDDMsg(String content,String... mobiles){
    JSONObject jsonObject= new JSONObject();
    jsonObject.put("msgtype","text");
    JSONObject contest= new JSONObject();


    JSONObject mobile= new JSONObject();
    StringBuffer sb= new StringBuffer(content);

    if(mobiles!=null && mobiles.length>0){
        List<String> list= new ArrayList<>();
        for(String m:mobiles){
            list.add(m);
            sb.append("@"+m+";");
        }
        mobile.put("atMobiles",list);
    }else{
        mobile.put("isAtAll",false);
    }

    contest.put("content",sb.toString());

    jsonObject.put("text",contest.toJSONString());
    jsonObject.put("at",mobile.toJSONString());
    return jsonObject.toJSONString();
}
 
Example 3
Source Project: jeewx-api   File: JwMessageAPI.java    License: Apache License 2.0 6 votes vote down vote up
public static int sendVideoMessage(Video video, String accessToken,String agentid) {  
	logger.info("[CREATEMENU]", "createText param:accessToken:{},agentid:{},video:{}", new Object[]{accessToken,agentid,video});
    int result = 0;  
    // 拼装发送信息的url  
    String url = message_send_url.replace("ACCESS_TOKEN", accessToken).replace("AGENTID", agentid);  
    // 将信息对象转换成json字符串  
    String jsonVideo = JSONObject.toJSONString(video);  
    logger.info("[CREATEMENU]", "sendMessage param:jsonText:{}", new Object[]{jsonVideo});
    // 调用接口发送信息 
    JSONObject jsonObject = HttpUtil.sendPost(url, jsonVideo);  
    logger.info("[CREATEMENU]", "sendMessage response:{}", new Object[]{jsonObject.toJSONString()});
    if (null != jsonObject) {  
    	int errcode = jsonObject.getIntValue("errcode");
        result = errcode;
    }  
    return result;  
}
 
Example 4
/**
 * 保存报修信息信息 到 instance
 * @param info   bId 信息
 * @throws DAOException DAO异常
 */
@Override
public void saveRepairInfoInstance(Map info) throws DAOException {
    logger.debug("保存报修信息信息Instance 入参 info : {}",info);

    int saveFlag = sqlSessionTemplate.insert("repairServiceDaoImpl.saveRepairInfoInstance",info);

    if(saveFlag < 1){
        throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存报修信息信息Instance数据失败:"+ JSONObject.toJSONString(info));
    }
}
 
Example 5
/**
 * 工作流节点信息封装
 * @param businessWorkflowStepInfo 工作流节点信息 封装
 * @throws DAOException DAO异常
 */
@Override
public void saveBusinessWorkflowStepInfo(Map businessWorkflowStepInfo) throws DAOException {
    businessWorkflowStepInfo.put("month", DateUtil.getCurrentMonth());
    // 查询business_user 数据是否已经存在
    logger.debug("保存工作流节点信息 入参 businessWorkflowStepInfo : {}",businessWorkflowStepInfo);
    int saveFlag = sqlSessionTemplate.insert("workflowStepServiceDaoImpl.saveBusinessWorkflowStepInfo",businessWorkflowStepInfo);

    if(saveFlag < 1){
        throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存工作流节点数据失败:"+ JSONObject.toJSONString(businessWorkflowStepInfo));
    }
}
 
Example 6
Source Project: SpringBootLearn   File: TestController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 正则查询
 * @return
 */
@GetMapping("/queryRegexpData")
public String queryRegexpData() {
    QueryBuilder queryBuilder = QueryBuilders.regexpQuery("name.keyword", "书名[0-9]{1,7}");
    List<Map<String, Object>> list = ElasticsearchUtil.searchListData(indexName, esType, queryBuilder, 10, null, null, null);
    return JSONObject.toJSONString(list);
}
 
Example 7
Source Project: xxpay-master   File: PayOrderController.java    License: MIT License 5 votes vote down vote up
String getJsonParam(String[] names, Object[] values) {
    JSONObject jsonParam = new JSONObject();
    for (int i = 0; i < names.length; i++) {
        jsonParam.put(names[i], values[i]);
    }
    return jsonParam.toJSONString();
}
 
Example 8
Source Project: das   File: ProjectControllerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void getGroupUsers() throws Exception {
    Paging<ProjectView> paging = new Paging<>();
    paging.setData(new ProjectView());
    String requestJson = JSONObject.toJSONString(paging);
    mockMvc.perform(MockMvcRequestBuilders.post("/project/list")
            .contentType(MediaType.APPLICATION_JSON_UTF8)
            .content(requestJson)
            .accept(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andDo(MockMvcResultHandlers.print());
}
 
Example 9
/**
 * 修改工作流节点信息
 * @param info 修改信息
 * @throws DAOException DAO异常
 */
@Override
public void updateWorkflowStepStaffInfoInstance(Map info) throws DAOException {
    logger.debug("修改工作流节点信息Instance 入参 info : {}",info);

    int saveFlag = sqlSessionTemplate.update("workflowStepStaffServiceDaoImpl.updateWorkflowStepStaffInfoInstance",info);

    if(saveFlag < 1){
        throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改工作流节点信息Instance数据失败:"+ JSONObject.toJSONString(info));
    }
}
 
Example 10
/**
 * 业主房屋信息封装
 *
 * @param businessOwnerRoomRelInfo 业主房屋信息 封装
 * @throws DAOException DAO异常
 */
@Override
public void saveBusinessOwnerRoomRelInfo(Map businessOwnerRoomRelInfo) throws DAOException {
    businessOwnerRoomRelInfo.put("month", DateUtil.getCurrentMonth());
    // 查询business_user 数据是否已经存在
    logger.debug("保存业主房屋信息 入参 businessOwnerRoomRelInfo : {}", businessOwnerRoomRelInfo);
    int saveFlag = sqlSessionTemplate.insert("ownerRoomRelServiceDaoImpl.saveBusinessOwnerRoomRelInfo", businessOwnerRoomRelInfo);

    if (saveFlag < 1) {
        throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "保存业主房屋数据失败:" + JSONObject.toJSONString(businessOwnerRoomRelInfo));
    }
}
 
Example 11
Source Project: xxpay-master   File: TransOrderDemo.java    License: MIT License 5 votes vote down vote up
static String quryPayOrderTest(String mchOrderNo, String payOrderId) {
    JSONObject paramMap = new JSONObject();
    paramMap.put("mchId", mchId);                               // 商户ID
    paramMap.put("mchOrderNo", mchOrderNo);                     // 商户订单号
    paramMap.put("payOrderId", payOrderId);                     // 支付订单号
    paramMap.put("executeNotify", "true");                      // 是否执行回调,true或false,如果为true当订单状态为支付成功(2)时,支付中心会再次回调一次业务系统

    String reqSign = PayDigestUtil.getSign(paramMap, reqKey);
    paramMap.put("sign", reqSign);                              // 签名
    String reqData = "params=" + paramMap.toJSONString();
    System.out.println("请求支付中心查单接口,请求数据:" + reqData);
    String url = baseUrl + "/pay/query_order?";
    String result = XXPayUtil.call4Post(url + reqData);
    System.out.println("请求支付中心查单接口,响应数据:" + result);
    Map retMap = JSON.parseObject(result);
    if("SUCCESS".equals(retMap.get("retCode")) && "SUCCESS".equalsIgnoreCase(retMap.get("resCode").toString())) {
        // 验签
        String checkSign = PayDigestUtil.getSign(retMap, repKey, "sign", "payParams");
        String retSign = (String) retMap.get("sign");
        if(checkSign.equals(retSign)) {
            System.out.println("=========支付中心查单验签成功=========");
        }else {
            System.err.println("=========支付中心查单验签失败=========");
            return null;
        }
    }
    return retMap.get("payOrderId")+"";
}
 
Example 12
/**
 * 车辆管理信息封装
 *
 * @param businessOwnerCarInfo 车辆管理信息 封装
 * @throws DAOException DAO异常
 */
@Override
public void saveBusinessOwnerCarInfo(Map businessOwnerCarInfo) throws DAOException {
    businessOwnerCarInfo.put("month", DateUtil.getCurrentMonth());
    // 查询business_user 数据是否已经存在
    logger.debug("保存车辆管理信息 入参 businessOwnerCarInfo : {}", businessOwnerCarInfo);
    int saveFlag = sqlSessionTemplate.insert("ownerCarServiceDaoImpl.saveBusinessOwnerCarInfo", businessOwnerCarInfo);

    if (saveFlag < 1) {
        throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "保存车辆管理数据失败:" + JSONObject.toJSONString(businessOwnerCarInfo));
    }
}
 
Example 13
/**
 * 修改小区单元信息
 *
 * @param info 修改信息
 * @throws DAOException
 */
@Override
public void updateUnitInfoInstance(Map info) throws DAOException {
    logger.debug("修改小区单元信息Instance 入参 info : {}", info);

    int saveFlag = sqlSessionTemplate.update("unitServiceDaoImpl.updateUnitInfoInstance", info);

    if (saveFlag < 1) {
        throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "修改小区单元信息Instance数据失败:" + JSONObject.toJSONString(info));
    }
}
 
Example 14
/**
 * 修改采购申请信息
 * @param info 修改信息
 * @throws DAOException DAO异常
 */
@Override
public void updatePurchaseApplyInfoInstance(Map info) throws DAOException {
    logger.debug("修改采购申请信息Instance 入参 info : {}",info);

    int saveFlag = sqlSessionTemplate.update("purchaseApplyServiceDaoImpl.updatePurchaseApplyInfoInstance",info);

    if(saveFlag < 1){
        throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改采购申请信息Instance数据失败:"+ JSONObject.toJSONString(info));
    }
}
 
Example 15
@ResponseBody
@RequestMapping(value = "/selectMockRuleResults")
public String selectMockRuleResults(HttpServletRequest arg0, Boolean selectFlag) throws Exception {
    JSONObject object = new JSONObject();
    object.put("result", "success");
    String method = null;
    String result = null;
    try {
        Map<String, String> context = Maps.newLinkedHashMap();
        String serviceId = arg0.getParameter("serviceId");
        String mockTestIds = arg0.getParameter("mockTestIds");
        String[] mocks = mockTestIds.split(",");
        Integer[] integers = new Integer[mocks.length];
        for (int i = 0; i < mocks.length; i++) {
            integers[i] = Integer.valueOf(mocks[i]);
        }
        String mockRules = arg0.getParameter("mockRules");
        mockRules = URLDecoder.decode(mockRules, Charset.defaultCharset().toString());
        String[] params = mockRules.split("&");
        List<String> mockKeys = Lists.newArrayList();
        List<String> mockValus = Lists.newArrayList();
        List<String> mockTypes = Lists.newArrayList();
        for (int i = 0; i < params.length; i++) {
            String[] param = params[i].split("=");
            if (param[0].equals("mockTestKey")) {
                if (i > 0 && ArrayUtils.contains(intelChars, param[1])) {
                    throw new RuntimeException("KEY命名不能包含以下关键字:" + ArrayUtils.toString(intelChars));
                }
                mockKeys.add(param[1]);
            }
            if (param[0].equals("mockTestValue")) {
                mockValus.add(param[1]);
            }
            if (param[0].equals("mockTestType")) {
                mockTypes.add(param[1]);
            }
        }
        for (int i = 0; i < mockKeys.size(); i++) {
            context.put(mockKeys.get(i), mockValus.get(i));
        }
        method = context.remove("methodName");
        result = mockTestServiceImpl.testMockService(Integer.valueOf(serviceId), method, context, integers);
    } catch (Exception e) {
        object.put("result", "error");
        result = e.getMessage();
        e.printStackTrace();
    }
    object.put("context", result);
    return object.toJSONString();
}
 
Example 16
Source Project: DDMQ   File: FastJsonUtils.java    License: Apache License 2.0 4 votes vote down vote up
public static String toJsonString(Object obj) {
    return JSONObject.toJSONString(obj, SerializerFeature.WriteDateUseDateFormat, SerializerFeature.WriteMapNullValue, SerializerFeature.DisableCircularReferenceDetect);
}
 
Example 17
Source Project: light-reading-cloud   File: RequestQuery.java    License: MIT License 4 votes vote down vote up
@Override
public String toString(){
    return JSONObject.toJSONString(this);
}
 
Example 18
public static String printCreateTransaction(Transaction transaction, boolean selfType) {
    JSONObject jsonObject = printTransactionToJSON(transaction, selfType);
    jsonObject.put(VISIBLE, selfType);
    return jsonObject.toJSONString();
}
 
Example 19
Source Project: MicroCommunity   File: PageData.java    License: Apache License 2.0 4 votes vote down vote up
public String toString() {
    return JSONObject.toJSONString(this);
}
 
Example 20
Source Project: xian   File: Input.java    License: Apache License 2.0 4 votes vote down vote up
@Override
final public String toString() {
    return JSONObject.toJSONString(this);
}