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

The following examples show how to use com.alibaba.fastjson.JSONObject#toJSONString() . 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: JwMenuAPI.java    From jeewx-api with 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 File: JwMessageAPI.java    From jeewx-api with 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 3
Source File: AbstractSendNotice.java    From JobX with 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 4
Source File: RepairServiceDaoImpl.java    From MicroCommunity with Apache License 2.0 5 votes vote down vote up
/**
 * 保存报修信息信息 到 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
Source File: WorkflowStepServiceDaoImpl.java    From MicroCommunity with Apache License 2.0 5 votes vote down vote up
/**
 * 工作流节点信息封装
 * @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 File: TestController.java    From SpringBootLearn with 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 File: PayOrderController.java    From xxpay-master with 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 File: PurchaseApplyServiceDaoImpl.java    From MicroCommunity with Apache License 2.0 5 votes vote down vote up
/**
 * 修改采购申请信息
 * @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 9
Source File: ProjectControllerTest.java    From das with 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 10
Source File: UnitServiceDaoImpl.java    From MicroCommunity with Apache License 2.0 5 votes vote down vote up
/**
 * 修改小区单元信息
 *
 * @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 11
Source File: WorkflowStepStaffServiceDaoImpl.java    From MicroCommunity with Apache License 2.0 5 votes vote down vote up
/**
 * 修改工作流节点信息
 * @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 12
Source File: OwnerRoomRelServiceDaoImpl.java    From MicroCommunity with Apache License 2.0 5 votes vote down vote up
/**
 * 业主房屋信息封装
 *
 * @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 13
Source File: TransOrderDemo.java    From xxpay-master with 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 14
Source File: OwnerCarServiceDaoImpl.java    From MicroCommunity with Apache License 2.0 5 votes vote down vote up
/**
 * 车辆管理信息封装
 *
 * @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 15
Source File: Input.java    From xian with Apache License 2.0 4 votes vote down vote up
@Override
final public String toString() {
    return JSONObject.toJSONString(this);
}
 
Example 16
Source File: PageData.java    From MicroCommunity with Apache License 2.0 4 votes vote down vote up
public String toString() {
    return JSONObject.toJSONString(this);
}
 
Example 17
Source File: Util.java    From gsc-core with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static String printCreateTransaction(Transaction transaction, boolean selfType) {
    JSONObject jsonObject = printTransactionToJSON(transaction, selfType);
    jsonObject.put(VISIBLE, selfType);
    return jsonObject.toJSONString();
}
 
Example 18
Source File: RequestQuery.java    From light-reading-cloud with MIT License 4 votes vote down vote up
@Override
public String toString(){
    return JSONObject.toJSONString(this);
}
 
Example 19
Source File: FastJsonUtils.java    From DDMQ with 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 20
Source File: MockOperDefineController.java    From dubbo-mock with Apache License 2.0 4 votes vote down vote up
@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();
}