當前位置: 首頁>>代碼示例>>Java>>正文


Java JSONObject.toJSON方法代碼示例

本文整理匯總了Java中com.alibaba.fastjson.JSONObject.toJSON方法的典型用法代碼示例。如果您正苦於以下問題:Java JSONObject.toJSON方法的具體用法?Java JSONObject.toJSON怎麽用?Java JSONObject.toJSON使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.alibaba.fastjson.JSONObject的用法示例。


在下文中一共展示了JSONObject.toJSON方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: list

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
@RequestMapping("/list")
@ResponseBody
public String list(@ModelAttribute PayChannel payChannel, Integer pageIndex, Integer pageSize) {
    PageModel pageModel = new PageModel();
    int count = payChannelService.count(payChannel);
    if(count <= 0) return JSON.toJSONString(pageModel);
    List<PayChannel> payChannelList = payChannelService.getPayChannelList((pageIndex-1)*pageSize, pageSize, payChannel);
    if(!CollectionUtils.isEmpty(payChannelList)) {
        JSONArray array = new JSONArray();
        for(PayChannel pc : payChannelList) {
            JSONObject object = (JSONObject) JSONObject.toJSON(pc);
            object.put("createTime", DateUtil.date2Str(pc.getCreateTime()));
            array.add(object);
        }
        pageModel.setList(array);
    }
    pageModel.setCount(count);
    pageModel.setMsg("ok");
    pageModel.setRel(true);
    return JSON.toJSONString(pageModel);
}
 
開發者ID:ywtnhm,項目名稱:pay-xxpay-master,代碼行數:22,代碼來源:PayChannelController.java

示例2: list

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
@RequestMapping("/list")
@ResponseBody
public String list(@ModelAttribute PayOrder payOrder, Integer pageIndex, Integer pageSize) {
    PageModel pageModel = new PageModel();
    int count = payOrderService.count(payOrder);
    if(count <= 0) return JSON.toJSONString(pageModel);
    List<PayOrder> payOrderList = payOrderService.getPayOrderList((pageIndex-1)*pageSize, pageSize, payOrder);
    if(!CollectionUtils.isEmpty(payOrderList)) {
        JSONArray array = new JSONArray();
        for(PayOrder po : payOrderList) {
            JSONObject object = (JSONObject) JSONObject.toJSON(po);
            if(po.getCreateTime() != null) object.put("createTime", DateUtil.date2Str(po.getCreateTime()));
            if(po.getAmount() != null) object.put("amount", AmountUtil.convertCent2Dollar(po.getAmount()+""));
            array.add(object);
        }
        pageModel.setList(array);
    }
    pageModel.setCount(count);
    pageModel.setMsg("ok");
    pageModel.setRel(true);
    return JSON.toJSONString(pageModel);
}
 
開發者ID:ywtnhm,項目名稱:pay-xxpay-master,代碼行數:23,代碼來源:PayOrderController.java

示例3: list

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
@RequestMapping("/list")
@ResponseBody
public String list(@ModelAttribute MchInfo mchInfo, Integer pageIndex, Integer pageSize) {
    PageModel pageModel = new PageModel();
    int count = mchInfoService.count(mchInfo);
    if(count <= 0) return JSON.toJSONString(pageModel);
    List<MchInfo> mchInfoList = mchInfoService.getMchInfoList((pageIndex-1)*pageSize, pageSize, mchInfo);
    if(!CollectionUtils.isEmpty(mchInfoList)) {
        JSONArray array = new JSONArray();
        for(MchInfo mi : mchInfoList) {
            JSONObject object = (JSONObject) JSONObject.toJSON(mi);
            object.put("createTime", DateUtil.date2Str(mi.getCreateTime()));
            array.add(object);
        }
        pageModel.setList(array);
    }
    pageModel.setCount(count);
    pageModel.setMsg("ok");
    pageModel.setRel(true);
    return JSON.toJSONString(pageModel);
}
 
開發者ID:ywtnhm,項目名稱:pay-xxpay-master,代碼行數:22,代碼來源:MchInfoController.java

示例4: list

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
@RequestMapping("/list")
@ResponseBody
public String list(@ModelAttribute MchNotify mchNotify, Integer pageIndex, Integer pageSize) {
    PageModel pageModel = new PageModel();
    int count = mchNotifyService.count(mchNotify);
    if(count <= 0) return JSON.toJSONString(pageModel);
    List<MchNotify> mchNotifyList = mchNotifyService.getMchNotifyList((pageIndex-1)*pageSize, pageSize, mchNotify);
    if(!CollectionUtils.isEmpty(mchNotifyList)) {
        JSONArray array = new JSONArray();
        for(MchNotify po : mchNotifyList) {
            JSONObject object = (JSONObject) JSONObject.toJSON(po);
            if(po.getCreateTime() != null) object.put("createTime", DateUtil.date2Str(po.getCreateTime()));
            if(po.getLastNotifyTime() != null) object.put("lastNotifyTime", DateUtil.date2Str(po.getLastNotifyTime()));
            array.add(object);
        }
        pageModel.setList(array);
    }
    pageModel.setCount(count);
    pageModel.setMsg("ok");
    pageModel.setRel(true);
    return JSON.toJSONString(pageModel);
}
 
開發者ID:jmdhappy,項目名稱:xxpay-master,代碼行數:23,代碼來源:MchNotifyController.java

示例5: list

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
@RequestMapping("/list")
@ResponseBody
public String list(@ModelAttribute RefundOrder refundOrder, Integer pageIndex, Integer pageSize) {
    PageModel pageModel = new PageModel();
    int count = refundOrderService.count(refundOrder);
    if(count <= 0) return JSON.toJSONString(pageModel);
    List<RefundOrder> refundOrderList = refundOrderService.getRefundOrderList((pageIndex-1)*pageSize, pageSize, refundOrder);
    if(!CollectionUtils.isEmpty(refundOrderList)) {
        JSONArray array = new JSONArray();
        for(RefundOrder po : refundOrderList) {
            JSONObject object = (JSONObject) JSONObject.toJSON(po);
            if(po.getCreateTime() != null) object.put("createTime", DateUtil.date2Str(po.getCreateTime()));
            if(po.getRefundAmount() != null) object.put("amount", AmountUtil.convertCent2Dollar(po.getRefundAmount()+""));
            array.add(object);
        }
        pageModel.setList(array);
    }
    pageModel.setCount(count);
    pageModel.setMsg("ok");
    pageModel.setRel(true);
    return JSON.toJSONString(pageModel);
}
 
開發者ID:jmdhappy,項目名稱:xxpay-master,代碼行數:23,代碼來源:RefundOrderController.java

示例6: list

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
@RequestMapping("/list")
@ResponseBody
public String list(@ModelAttribute TransOrder transOrder, Integer pageIndex, Integer pageSize) {
    PageModel pageModel = new PageModel();
    int count = transOrderService.count(transOrder);
    if(count <= 0) return JSON.toJSONString(pageModel);
    List<TransOrder> transOrderList = transOrderService.getTransOrderList((pageIndex-1)*pageSize, pageSize, transOrder);
    if(!CollectionUtils.isEmpty(transOrderList)) {
        JSONArray array = new JSONArray();
        for(TransOrder po : transOrderList) {
            JSONObject object = (JSONObject) JSONObject.toJSON(po);
            if(po.getCreateTime() != null) object.put("createTime", DateUtil.date2Str(po.getCreateTime()));
            if(po.getAmount() != null) object.put("amount", AmountUtil.convertCent2Dollar(po.getAmount()+""));
            array.add(object);
        }
        pageModel.setList(array);
    }
    pageModel.setCount(count);
    pageModel.setMsg("ok");
    pageModel.setRel(true);
    return JSON.toJSONString(pageModel);
}
 
開發者ID:jmdhappy,項目名稱:xxpay-master,代碼行數:23,代碼來源:TransOrderController.java

示例7: convertObjectToJSONObject

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
/**
 * <B>方法名稱:</B>將對象轉為JSONObject對象<BR>
 * <B>概要說明:</B>將對象轉為JSONObject對象<BR>
 * @param obj 任意對象
 * @return JSONObject對象
 */
public static JSONObject convertObjectToJSONObject(Object obj){
	try {
		JSONObject jsonObject = (JSONObject) JSONObject.toJSON(obj);
		return jsonObject;
	} catch (Exception e) {
		e.printStackTrace();
		return null;
	}		
}
 
開發者ID:xubinux,項目名稱:xbin-store,代碼行數:16,代碼來源:FastJsonConvert.java

示例8: notifyRunStatus

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
private void notifyRunStatus(DrawGuessContext ctx) {
    ApiResponse response = service.borrowObject();
    try {
        String currentUser = ctx.getCurrentUser();
        JSONObject content = (JSONObject) JSONObject.toJSON(ctx);
        response.setCode(DrawCode.GAME_UPDATE.getCode()).setData(content);
        webSocket.sendTo(webSocket.transformToMsg(response.setData(content)), currentUser);
        content.getJSONObject("currentWord").remove("word"); // 廣播消息去除敏感信息
        TextMessage textMessage = webSocket.transformToMsg(response);
        webSocket.broadcast(textMessage, currentUser);
    } finally {
        service.returnObject(response);
    }
}
 
開發者ID:csdbianhua,項目名稱:telemarket-skittle-alley,代碼行數:15,代碼來源:DrawGuessAspect.java

示例9: mergeConfigParamRouter

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
/**
 * @param result
 * @param tmpParamRouterMapForUpdate
 */
public void mergeConfigParamRouter(Map<String, Map<String, String>> result,
		Map<String, Map<String, String>> tmpParamRouterMapForUpdate) {
	if( tmpParamRouterMapForUpdate != null && !tmpParamRouterMapForUpdate.isEmpty()){
           logger.info(" param router config " + tmpParamRouterMapForUpdate);
           //添加參數路由配置
           for (Map.Entry<String, Map<String, String>> entry : tmpParamRouterMapForUpdate.entrySet()) {
               JSONObject paramRouterJSON = (JSONObject) JSONObject.toJSON(entry.getValue());
               if (result.get(entry.getKey()) == null) {
                   result.put(entry.getKey(), new HashMap<String, String>());
               }
               result.get(entry.getKey()).put(Constants.SETTING_ROUTER_RULE, paramRouterJSON.toJSONString());
           }
       }
}
 
開發者ID:tiglabs,項目名稱:jsf-core,代碼行數:19,代碼來源:ConfigHelper.java

示例10: mergeConfigAliasRouter

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
/**
 * @param result
 * @param tmpAliasRouterMapForUpdate
 */
public void mergeConfigAliasRouter(Map<String, Map<String, String>> result, Map<String, Map<String, String>> tmpAliasRouterMapForUpdate) {
	if( tmpAliasRouterMapForUpdate != null && !tmpAliasRouterMapForUpdate.isEmpty()){
		logger.info(" alias router config " + tmpAliasRouterMapForUpdate);
		//添加分組路由配置
		for (Map.Entry<String, Map<String, String>> entry : tmpAliasRouterMapForUpdate.entrySet()) {
			JSONObject aliasRouterJSON = (JSONObject) JSONObject.toJSON(entry.getValue());
			if (result.get(entry.getKey()) == null) {
				result.put(entry.getKey(), new HashMap<String, String>());
			}
			result.get(entry.getKey()).put(RegistryConstants.SETTING_MAP_PARAM_ALIAS, aliasRouterJSON.toJSONString());
		}
	}
}
 
開發者ID:tiglabs,項目名稱:jsf-core,代碼行數:18,代碼來源:ConfigHelper.java

示例11: saveWorkerParameters

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
@Override
public void saveWorkerParameters(ScheduleServer currentServer, JSONObject parameters) {
    String zkPath = "/"+Constants.SAF_WORKER_ROOT+"/"+currentServer.getWorkerType()+"/"+Constants.SAF_WORKER_SERVER+"/"+currentServer.getId();
    JSONObject serverJSON = (JSONObject) JSONObject.toJSON(currentServer);
    byte[] serverValue = serverJSON.toJSONString().getBytes();
    try {
        zkClient.writeData(zkPath,serverValue);
    } catch (Exception e) {
        logger.error(" save [{}] parameters on server {} failed",currentServer.getWorkerType(),currentServer.getId(),e);
    }
}
 
開發者ID:tiglabs,項目名稱:jsf-core,代碼行數:12,代碼來源:DefaultScheduleDataManager.java

示例12: tryToJSONObject

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
public static JSONObject tryToJSONObject(Object javaObject){
    if (javaObject == null) {
        return null;
    }

    if (javaObject instanceof JSONObject) {
        return (JSONObject) javaObject;
    }

    if (javaObject instanceof Collection<?>) {
        return null;
    }
    Class<?> cls = javaObject.getClass();
    if (cls.isArray()) {
        return null;
    }
    if (cls.isEnum()) {
        return null;
    }
    if (isPrimitive(cls)) {
        return null;
    }

    Object obj = JSONObject.toJSON(javaObject);
    if (obj instanceof JSONObject) {
        return (JSONObject) obj;
    }

    return null;
}
 
開發者ID:bubicn,項目名稱:bubichain-sdk-java,代碼行數:31,代碼來源:JSONBean.java

示例13: toJSONObject

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
private static JSONObject toJSONObject(Object javaObject){
    if (javaObject == null) {
        throw new IllegalArgumentException("The wrapped java object is null!");
    }

    if (javaObject instanceof JSONObject) {
        return (JSONObject) javaObject;
    }

    if (javaObject instanceof Collection<?>) {
        throw new IllegalArgumentException("The wrapped java object is a collection!");
    }
    Class<?> cls = javaObject.getClass();
    if (cls.isArray()) {
        throw new IllegalArgumentException("The wrapped java object is a array!");
    }
    if (cls.isEnum()) {
        throw new IllegalArgumentException("The wrapped java object is a enum!");
    }
    if (isPrimitive(cls)) {
        throw new IllegalArgumentException("The wrapped java object is a primitive value!");
    }

    Object obj = JSONObject.toJSON(javaObject);
    if (obj instanceof JSONObject) {
        return (JSONObject) obj;
    }

    throw new IllegalArgumentException("The wrapped java object cann't be converted to a JSON Object!");
}
 
開發者ID:bubicn,項目名稱:bubichain-sdk-java,代碼行數:31,代碼來源:JSONBean.java

示例14: getJSONObjectFromObj

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
public static JSONObject getJSONObjectFromObj(Object object) {
    if (object == null) {
        return null;
    }
    return (JSONObject) JSONObject.toJSON(object);
}
 
開發者ID:ywtnhm,項目名稱:pay-xxpay-master,代碼行數:7,代碼來源:JsonUtil.java


注:本文中的com.alibaba.fastjson.JSONObject.toJSON方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。