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


Java JSONObject.getJSONArray方法代碼示例

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


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

示例1: queryBranch

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
/** 查詢支行信息 */
public JSONArray queryBranch(LianlianBankType bankType, String cityCode) {
	JSONObject post = new JSONObject();
	post.put("oid_partner", this.merchantId);
	post.put("sign_type", this.signType);
	post.put("card_no", "");
	post.put("bank_code", bankType.getCode());
	post.put("brabank_name", "銀行");// 關鍵字
	post.put("city_code", cityCode);
	// 加簽名
	String sign = LianlianPayUtil.addSign(post, this.privateKey, this.md5Key);
	post.put("sign", sign);
	String text = this.sendHttpPost(this.queryUrl, post.toString());
	logger.info("連連支付返回:" + text);

	JSONObject result = JSONObject.parseObject(text);
	if (!"0000".equals(result.getString("ret_code"))) {
		return null;
	}
	return result.getJSONArray("card_list");
}
 
開發者ID:yi-jun,項目名稱:aaden-pay,代碼行數:22,代碼來源:LianlianClient.java

示例2: getTags

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
public static List<Tag> getTags (boolean useCache) throws APIException {
    if (DEBUG) Log.i(TAG, "-> getTags");
    try {
        String text = NetworkUtil.get(ApiManager.API_TAGS, useCache);
        if (DEBUG) Log.i(TAG, "-> get -> success");
        JSONObject root = JSON.parseObject(text);
        JSONArray data = root.getJSONArray("data");
        List<Tag> tags = new ArrayList<>();
        for (int i = 0; i < data.size(); i ++) {
            JSONObject object = data.getJSONObject(i);
            Tag tag = getTag(object.getInteger("id"), object);
            if (DEBUG) Log.i(TAG, "Adding " + tag.toString());
            tags.add(tag);
        }
        return tags;
    } catch (IOException|JSONException e) {
        throw new APIException(e);
    }
}
 
開發者ID:ProjectFishpond,項目名稱:TPondof,代碼行數:20,代碼來源:TagManager.java

示例3: getObject

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
/**
 * read the json file and transform into memory
 *
 * @return
 * @throws Exception
 */
public Map<String, Map<String, String>> getObject() throws Exception {
    Map<String, Map<String, String>> result = new ConcurrentHashMap<String, Map<String, String>>();
    String jsonString = readFromFile();
    JSONArray jsonArray = JSONObject.parseArray(jsonString);
    if (jsonArray != null) {
        for (Object schema : jsonArray) {
            JSONObject x = (JSONObject) schema;
            String schemaName = x.getString("schema");
            JSONArray viewList = x.getJSONArray("list");
            Map<String, String> schemaView = new ConcurrentHashMap<String, String>();
            for (Object view : viewList) {
                JSONObject y = (JSONObject) view;
                schemaView.put(y.getString("name"), y.getString("sql"));
            }
            result.put(schemaName, schemaView);
        }
    }
    return result;
}
 
開發者ID:actiontech,項目名稱:dble,代碼行數:26,代碼來源:FileSystemRepository.java

示例4: processTypeResult

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
/**
 * 對返回值進行處理
 * @param str
 * @return text
 */
public String processTypeResult(String str){
	System.out.println("textTypeResult:"+str);
	JSONObject jsonObject = JSONObject.parseObject(str);
	String code = jsonObject.getString("code");
	if(TEXT_CODE.equals(code)){
		return jsonObject.getString("text");
	}else if(LINK_CODE.equals(code)){
		return jsonObject.getString("text")+"\n"+jsonObject.getString("url");
	} else if (NEWS_CODE.equals(code)) {
		JSONArray array = jsonObject.getJSONArray("list");
		int size = 5;
		if (array.size() < 5) {
			size = array.size();
		}
		List<Article> list = new ArrayList<>();
		for (int i = 0; i < size; i++) {
			JSONObject object = array.getJSONObject(i);
			Article article = new Article(object.getString("article"), object.getString("source"), object.getString("icon"), object.getString("detailurl"));
			list.add(article);
		}
		return list.toString();
	}else{
		return "對不起,沒聽清楚,再說一遍吧。";
	}
}
 
開發者ID:CharleyXu,項目名稱:tulingchat,代碼行數:31,代碼來源:TulingRobotUtil.java

示例5: playUrl

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
@RequestMapping(value = "playUrl", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
@ResponseBody
public ReturnT<JSONArray> playUrl(Model model, HttpServletRequest request, @RequestParam("uid") String uid) {
    HeadPrinter.printHead(model);
    JSONObject jsonObject1 = JSONObject.parseObject(uid);
    long id = jsonObject1.getLongValue("uid");
    String result = NetEaseClient.getPlayUrl(id);
    JSONObject jsonObject = JSONObject.parseObject(result);
    String ly = "";
    JSONArray jsonArray = jsonObject.getJSONArray("data");
    return new ReturnT(jsonArray, ly);
}
 
開發者ID:wxz1211,項目名稱:dooo,代碼行數:13,代碼來源:NetEaseController.java

示例6: test_for_issue

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
public void test_for_issue() throws Exception {
    String text = "{\"resultObj\":{\"assetSize\":{},\"chargeTypeList\":[\"A\"],\"fundManagerMapList\":[{},{}],\"fundRateConvertList\":[{},{},{}],\"fundRateOperate\":{},\"fundRatePurchaseList\":[{\"fixedRate\":{},\"maxAmount\":{},\"minAmount\":{}}],\"fundRateRedeemList\":[{\"fixedRate\":{}}],\"fundRateSubscribeList\":[{\"fixedRate\":{},\"maxAmount\":{},\"minAmount\":{}}],\"fundRatingList\":[{},{}],\"fundRuleConvertList\":[{},{}],\"fundRuleConvertVoList\":[{\"fundRateConvertList\":[{\"$ref\":\"$.resultObj.fundRateConvertList[0]\"},{\"$ref\":\"$.resultObj.fundRateConvertList[1]\"}],\"fundRuleConvert\":{\"$ref\":\"$.resultObj.fundRuleConvertList[0]\"}},{\"fundRateConvertList\":[{\"$ref\":\"$.resultObj.fundRateConvertList[2]\"}],\"fundRuleConvert\":{\"$ref\":\"$.resultObj.fundRuleConvertList[1]\"}}]}}";
    JSONObject root = JSON.parseObject(text);

    JSONObject resultObj = root.getJSONObject("resultObj");
    assertNotNull(resultObj);

    JSONArray fundRuleConvertVoList = resultObj.getJSONArray("fundRuleConvertVoList");
    assertNotNull(fundRuleConvertVoList);

    JSONArray fundRateConvertList = fundRuleConvertVoList.getJSONObject(0).getJSONArray("fundRateConvertList");
    assertNotNull(fundRateConvertList);

    assertNotNull(fundRateConvertList.get(0));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:16,代碼來源:Alipay1213.java

示例7: getBaseUnitTagMap

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
public Map<String, String> getBaseUnitTagMap() throws IOException {
    Map<String, String> tagMap = new HashMap<>();
    if (null != this.apContext.getApExploredFolder()
        && this.apContext.getApExploredFolder().exists()) {
        File file = new File(this.apContext.getApExploredFolder(), "atlasFrameworkProperties.json");
        if (file.exists()) {
            JSONObject jsonObject = (JSONObject)JSON.parse(org.apache.commons.io.FileUtils.readFileToString(file));
            JSONArray jsonArray = jsonObject.getJSONArray("bundleInfo");
            for (JSONObject obj : jsonArray.toArray(new JSONObject[0])) {
                tagMap.put(obj.getString("pkgName"), obj.getString("unique_tag"));
            }
        }
    }
    return tagMap;
}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:16,代碼來源:AppVariantContext.java

示例8: onEvent

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
@Override
public void onEvent(CustomNotification customNotification) {
    try {
        JSONObject jsonObject = parseContentJson(customNotification);
        // 收到群視頻邀請
        if (isTeamAVChatInvite(jsonObject)) {
            final String roomName = jsonObject.getString(KEY_RID);
            final String teamId = jsonObject.getString(KEY_TID);
            JSONArray accountArray = jsonObject.getJSONArray(KEY_MEMBER);
            final ArrayList<String> accounts = new ArrayList<>();
            final String teamName = jsonObject.getString(KEY_TNAME);
            if (accountArray != null) {
                for (Object o : accountArray) {
                    accounts.add((String) o);
                }
            }

            // 接收到群視頻邀請,啟動來點界麵
            LogUtil.ui("receive team video chat notification " + teamId + " room " + roomName);
            if (isTeamAVChatting || AVChatProfile.getInstance().isAVChatting()) {
                LogUtil.ui("cancel launch team av chat isTeamAVChatting = " + isTeamAVChatting);
                Toast.makeText(DemoCache.getContext(), "正在進行視頻通話", Toast.LENGTH_SHORT).show();
                return;
            }
            LogUtil.ui("isSyncComplete = " + isSyncComplete);
            if (isSyncComplete || !checkOfflineOutTime(customNotification)) {
                isTeamAVChatting = true;
                launchActivity(teamId, roomName, accounts, teamName);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:newDeepLearing,項目名稱:decoy,代碼行數:35,代碼來源:TeamAVChatHelper.java

示例9: test_jsonpath

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
public void test_jsonpath() throws Exception {
    JSONObject rootObject = JSON.parseObject("{\"array\":[{},{},{},{}]}");
    JSONPath.set(rootObject, "$.array[0:].key", "123");

    JSONArray array = rootObject.getJSONArray("array");
    for (int i = 0; i < array.size(); ++i) {
        Assert.assertEquals("123", array.getJSONObject(i).get("key"));
    }
    System.out.println(rootObject);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:11,代碼來源:JSONPath_set_test2.java

示例10: uncompactArrayFormat

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
private JSONArray uncompactArrayFormat(JSONObject jsonValue) {
    val head = jsonValue.getJSONArray("_h");
    val data = jsonValue.getJSONArray("_d");
    int arraySize = data.size() / head.size();
    val uncompacted = new JSONArray(arraySize);
    for (int i = 0; i < arraySize; i++) {
        val item = new JSONObject(head.size());
        uncompacted.add(item);

        for (int j = 0, jj = head.size(); j < jj; ++j)
            item.put(head.getString(j), data.get(i * jj + j));
    }

    return uncompacted;
}
 
開發者ID:bingoohuang,項目名稱:westjson,代碼行數:16,代碼來源:WestJsonUncompacter.java

示例11: test_parseMileage

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
@Test
public void test_parseMileage() {
    File file = new File("D:\\mileage.json");
    String json = readToString(file, "UTF-8");
    JSONObject jsonObject = JSON.parseObject(json);
    JSONObject data = jsonObject.getJSONObject("data");
    JSONArray dataArray = data.getJSONArray("result");
    double result = 0;
    for (int i = 0; i < dataArray.size(); i++) {
        JSONObject temp = JSON.parseObject(dataArray.get(i).toString());
        System.out.println("carNumber:"+temp.get("carNumber")+",mileage:"+temp.get("mileage"));
        result += Double.parseDouble(temp.get("mileage").toString());
    }
    System.out.println(result);
}
 
開發者ID:alamby,項目名稱:upgradeToy,代碼行數:16,代碼來源:ParseMileage.java

示例12: getDataJSONArray

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
/**
 * 返回列表數據, 反之返回空.
 * 
 * @return
 */
public JSONArray getDataJSONArray()
{
	if (data != null)
	{
		JSONObject jsonObject = JSONObject.parseObject(data);
		return jsonObject.getJSONArray("list");
	}

	return null;
}
 
開發者ID:benniaobuguai,項目名稱:android-project-gallery,代碼行數:16,代碼來源:Res.java

示例13: currentNodeInfo

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
/**
 * 當前節點的節點信息監控數據
 * @param rabbitMQ
 * @param nodeName
 * @return
 */
private List<DetectResult.Metric> currentNodeInfo(RabbitMQ rabbitMQ, String nodeName) {
    List<DetectResult.Metric> result = new ArrayList<>();
    String apiBody = getAPIResult(rabbitMQ,"api/nodes/" + nodeName);
    if (apiBody != null){
        JSONObject jsonObject = JSONObject.parseObject(apiBody);
        utilForParsingJSON(result,"fd_total","fd_total",jsonObject,CounterType.GAUGE,"");
        utilForParsingJSON(result,"mem_used","mem_used",jsonObject,CounterType.GAUGE,"");
        utilForParsingJSON(result,"sockets_used","sockets_used",jsonObject,CounterType.GAUGE,"");
        utilForParsingJSON(result,"run_queue","run_queue",jsonObject,CounterType.GAUGE,"");
        JSONArray partitions = jsonObject.getJSONArray("partitions");
        result.add(new DetectResult.Metric("partitions",String.valueOf(partitions.size()),CounterType.GAUGE,""));
    }
    return result;
}
 
開發者ID:DevopsJK,項目名稱:SuitAgent,代碼行數:21,代碼來源:RabbitMQPlugin.java

示例14: getLatestNews

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
/**
 * 最新
 */
public List<Article> getLatestNews() {
	String request = HttpClientUtil.sendGet(latestUrl, null, null);
	JSONObject jsonObject = JSONObject.parseObject(request);
	JSONArray top_stories = jsonObject.getJSONArray("top_stories");
	return getNewsListFromJsonArray(top_stories);
}
 
開發者ID:CharleyXu,項目名稱:tulingchat,代碼行數:10,代碼來源:DailyZhihuUtil.java

示例15: test_for_issue

import com.alibaba.fastjson.JSONObject; //導入方法依賴的package包/類
public void test_for_issue() throws Exception {
    String json = "{value:[\"null\"]}";
    JSONObject parse = JSONObject.parseObject(json);
    JSONArray jsonArray = parse.getJSONArray("value");
    Assert.assertEquals(1, jsonArray.size());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:7,代碼來源:Bug_for_issue_434.java


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