当前位置: 首页>>代码示例>>Java>>正文


Java JSONArray.add方法代码示例

本文整理汇总了Java中com.alibaba.fastjson.JSONArray.add方法的典型用法代码示例。如果您正苦于以下问题:Java JSONArray.add方法的具体用法?Java JSONArray.add怎么用?Java JSONArray.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.fastjson.JSONArray的用法示例。


在下文中一共展示了JSONArray.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: list

import com.alibaba.fastjson.JSONArray; //导入方法依赖的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

示例2: list

import com.alibaba.fastjson.JSONArray; //导入方法依赖的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

示例3: get

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
@Override
public JSONArray get(Condition query, QuerySettings querySettings, String key) throws DBException
{
    DBCursor cursor = null;
    try
    {
        cursor = dealQuerySettings(collection.find(checkToFinal(query), new BasicDBObject(key, 1)), querySettings);
        JSONArray list = new JSONArray(cursor.count());
        for (DBObject object : cursor)
        {
            list.add(object.get(key));
        }
        return list;
    } catch (Exception e)
    {
        throw new DBException(e);
    } finally
    {
        WPTool.close(cursor);
    }

}
 
开发者ID:gzxishan,项目名称:OftenPorter,代码行数:23,代码来源:MongoHandle.java

示例4: tree

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
/**
 * 获取所有机构列表
 * @return
 */
@ApiOperation(value = "字典管理-树层级结构接口")
@PostMapping("/tree")
@ResponseBody
public JSONArray tree(SysDict model) {
    JSONArray list=new JSONArray();
    List<SysDict> midList = service.getDicByParentId(model.getId());
    if(midList!=null){
        for (SysDict item:midList) {
            JSONObject obj=new JSONObject();
            obj.put("name",item.getLabel());
            obj.put("id",item.getValue());
            obj.put("pId",item.getParentId());
            obj.put("isParent",""+isHaveChild(item.getId()));
            list.add(obj);
        }
    }
    return list;
}
 
开发者ID:egojit8,项目名称:easyweb,代码行数:23,代码来源:DictController.java

示例5: handleRequest

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
@Override
public String handleRequest(IUser user, String jsonString) {
	List<Room> allRoom = RoomManager.getInstance().getAllRoom();
	JSONObject jsonObject=new JSONObject();
	JSONArray array=new JSONArray();
	for (Room object : allRoom) {
		JSONObject object2=new JSONObject();
		object2.put("id", object.getId());
		object2.put("size", object.getList().size());
		array.add(object2);
	}
	jsonObject.put("state", true);
	jsonObject.put("list", array);
	String jsonString2 = jsonObject.toString();
	System.out.println(jsonString2);
	return jsonString2;
}
 
开发者ID:zerosoft,项目名称:CodeBroker,代码行数:18,代码来源:GetAllRoomRequest.java

示例6: testSendAndOnObject

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
@Test
public void testSendAndOnObject() throws Exception {
    mClusterWS.connect();
    mClusterWS.on("String", new IEmitterListener() {
        @Override
        public void onDataReceived(Object data) {
            gotTheData = true;
            receivedData = data;
        }
    });
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("int", 30);
    jsonObject.put("bool", true);
    jsonObject.put("string", "CHLEN");
    JSONArray jsonArray = new JSONArray();
    jsonArray.add(30);
    jsonArray.add(true);
    jsonArray.add("CHLEN");
    jsonObject.put("array", jsonArray);
    Thread.sleep(1000);
    mClusterWS.send("String", jsonObject);
    Thread.sleep(1000);

    assertTrue("Did not get the data", gotTheData);
    assertEquals("Data send and data received are not the same", jsonObject.toString(), receivedData.toString());
}
 
开发者ID:ClusterWS,项目名称:ClusterWS-Client-Java,代码行数:27,代码来源:ClusterWSTest.java

示例7: list

import com.alibaba.fastjson.JSONArray; //导入方法依赖的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:jmdhappy,项目名称:xxpay-master,代码行数:23,代码来源:PayOrderController.java

示例8: getDefaultConfigInfo

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
/**
     * 
     * @see cn.benma666.kettle.steps.easyexpand.EasyExpandRunBase#getDefaultConfigInfo(org.pentaho.di.trans.TransMeta, java.lang.String)
     */
     @Override
     public String getDefaultConfigInfo() throws Exception{
        //创建一个JSON对象,用于构建配置对象,避免直接拼字符串构建JSON字符串
        JSONObject params = new JSONObject();
        //设置一个参数key1
        params.put("key1", "");
        //创建一个JSON数组对象,用于存放数组参数
        JSONArray arr = new JSONArray();
        arr.add("arr1");
        arr.add("arr2");
        params.put("array", arr);
        //生成的参数样例
        //{
        //  "array":[
        //          "arr1",
        //          "arr2"
        //  ],
        //  "key1":""
        //}
        //返回格式化后的默认JSON配置参数,供使用者方便快捷的修改配置
        return JSON.toJSONString(params, true);
//         return "select *\n from dual";
    }
 
开发者ID:majinju,项目名称:KettleUtil,代码行数:28,代码来源:JobEntryEasyExpandDemo.java

示例9: getOntologyList

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
@RequestMapping(value = "/get-ontology-list", method = RequestMethod.GET)
@ResponseBody
public JSONArray getOntologyList(@RequestParam(value = "type", required = false) String type) {
    logger.info(" [Http request get ontology list] type = {} ", type);
    List<Ontology> ontologyList;
    if (type == null || "".equals(type)) {
        ontologyList = ontologyService.getAllOntology();
    } else {
        ontologyList = ontologyService.getOntologyByType(type);
    }
    JSONArray jsonArray = new JSONArray();
    for (Ontology ontology : ontologyList) {
        JSONObject obj = new JSONObject(true);
        obj.put("key", ontology.getId());
        obj.put("name", ontology.getName());
        obj.put("type", ontology.getOntologyType() == null ? "" : ontology.getOntologyType().getName());
        obj.put("category_name", ontology.getOntologyCategory() == null ? "" : ontology.getOntologyCategory().getName());
        obj.put("valid", ontology.getValid());
        obj.put("creator", ontology.getCreator());
        obj.put("create_time", DateUtil.format(ontology.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
        obj.put("update_time", DateUtil.format(ontology.getUpdateTime(), "yyyy-MM-dd HH:mm:ss"));
        jsonArray.add(obj);
    }
    return jsonArray;
}
 
开发者ID:SnailFastGo,项目名称:ontology_setting,代码行数:26,代码来源:OntologyController.java

示例10: getOntologyProperties

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
@RequestMapping(value = "/get-ontology-property", method = RequestMethod.GET)
@ResponseBody
public JSONArray getOntologyProperties(@RequestParam(value = "key") Integer id) {
    logger.info(" [Http request get ontology property] id = {} ", id);
    List<OntologyProperty> ontologyProperties = ontologyPropertyService.getPropertiesByOntologyID(id);
    JSONArray jsonArray = new JSONArray();
    for (OntologyProperty ontologyProperty : ontologyProperties) {
        JSONObject obj = new JSONObject(true);
        obj.put("key", ontologyProperty.getId());
        obj.put("name", ontologyProperty.getName());
        obj.put("ontology_id", ontologyProperty.getOntology().getId());
        obj.put("source", ontologyProperty.getSource());
        obj.put("isKey", ontologyProperty.getKey());
        obj.put("isIndex", ontologyProperty.getIndex());
        obj.put("isValid", ontologyProperty.getValid());
        obj.put("creator", ontologyProperty.getCreator());
        obj.put("create_time", DateUtil.format(ontologyProperty.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
        obj.put("update_time", DateUtil.format(ontologyProperty.getUpdateTime(), "yyyy-MM-dd HH:mm:ss"));
        jsonArray.add(obj);
    }
    return jsonArray;
}
 
开发者ID:SnailFastGo,项目名称:ontology_setting,代码行数:23,代码来源:OntologyPropertyController.java

示例11: getBranchList

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
/**
 * 获取支行信息
 */
@RequestMapping(value = "/branchList", produces = "application/json;charset=UTF-8")
@ResponseBody
public JSONArray getBranchList(HttpServletRequest request, BankType bankType, String cityCode, String keyWord) {
	keyWord = keyWord == null ? "" : keyWord;
	List<IndexModel> list = bankService.queryBrank(cityCode, bankType, keyWord);
	JSONArray array = new JSONArray();
	if (list != null) {
		for (IndexModel item : list) {
			JSONObject json = new JSONObject();
			json.put("label", item.getIndexBody());
			json.put("value", item.getIndexBody());
			array.add(json);
		}
	}
	// {label:"中国银行广州支行",value:"中国银行广州支行"}
	return array;
}
 
开发者ID:yi-jun,项目名称:aaden-pay,代码行数:21,代码来源:CashController.java

示例12: testCallModuleMethod4

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
@Test
public void testCallModuleMethod4() throws Exception {
  JSONArray args = new JSONArray();
  args.add("testarg");
  args.add("testcallbackId");
  WXModuleManager.callModuleMethod(instance.getInstanceId(),"test1","testCallbackMethod",args);
}
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:8,代码来源:WXModuleManagerTest.java

示例13: validateIn

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
/**
* 包含 <br/>
* @author jingma
* @param object
* @param vi
* @param validateInfo
*/
private boolean validateIn(Object object, JSONObject vi, JSONArray validateInfo) {
    if(object==null){
        return true;
    }
    List<String> dataList = getValidateData(vi);
    boolean result = dataList.contains(object.toString());
    if(!result){
        vi.put(VALIDATE_VAL, object.toString());
        validateInfo.add(vi);
    }
    return result;
}
 
开发者ID:majinju,项目名称:KettleEasyExpand,代码行数:20,代码来源:DataValidate.java

示例14: buildContent

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
public String buildContent(String roomName, String teamID, List<String> accounts, String teamName) {
    JSONObject json = new JSONObject();
    json.put(KEY_ID, ID);
    JSONArray array = new JSONArray();
    array.add(DemoCache.getAccount());
    for (String account : accounts) {
        array.add(account);
    }
    json.put(KEY_MEMBER, array);
    json.put(KEY_TID, teamID);
    json.put(KEY_RID, roomName);
    json.put(KEY_TNAME, teamName);
    return json.toString();
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:15,代码来源:TeamAVChatHelper.java

示例15: convertArrayToJSONArray

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
private static JSONArray convertArrayToJSONArray(Object array) {
    JSONArray result = new JSONArray();
    for (int i = 0; i < Array.getLength(array); i++) {
        Object elementObject = Array.get(array, i);
        if (elementObject != null) {
            Object resultObject = convertElementToJSON(elementObject);
            result.add(resultObject);
        }
    }        
    return result;
}
 
开发者ID:ZhouKanZ,项目名称:SweepRobot,代码行数:12,代码来源:JSON.java


注:本文中的com.alibaba.fastjson.JSONArray.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。