當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。