当前位置: 首页>>代码示例>>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;未经允许,请勿转载。