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


Java JSONArray.size方法代码示例

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


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

示例1: getM15

import org.json.simple.JSONArray; //导入方法依赖的package包/类
public long getM15(String json) throws ParseException {
    long m15 = 0;
    if (json != null) {
        JSONParser parser = new JSONParser();
        JSONObject battleNetCharacter = (JSONObject) parser.parse(json);
        JSONObject achivements = (JSONObject) battleNetCharacter.get("achievements");
        JSONArray criteriaObject = (JSONArray) achivements.get("criteria");
        int criteriaNumber = -1;
        for (int i = 0; i < criteriaObject.size(); i++) {
            if ((long)criteriaObject.get(i) == 32028    ) {
                criteriaNumber = i;
            }
        }

        if (criteriaNumber != -1) {
            m15 = (long) ((JSONArray)achivements.get("criteriaQuantity")).get(criteriaNumber);
            if (m15 >= 1) {
                m15 += 1;
            }
        }
    }
    return m15;
}
 
开发者ID:greatman,项目名称:legendarybot,代码行数:24,代码来源:IlvlCommand.java

示例2: assertTasksPresentInTaskQuery

import org.json.simple.JSONArray; //导入方法依赖的package包/类
protected void assertTasksPresentInTaskQuery(Map<String, String> params, TasksClient tasksClient, boolean countShouldMatch, String ...taskIds) throws Exception 
{
    JSONObject taskListJSONObject = tasksClient.findTasks(params);
    assertNotNull(taskListJSONObject);
    JSONArray jsonEntries = (JSONArray) taskListJSONObject.get("entries");
    if(countShouldMatch) {
        assertEquals("Wrong amount of tasks returned by query", taskIds.length, jsonEntries.size());
    }
    
    List<String> tasksToFind = new ArrayList<String>();
    tasksToFind.addAll(Arrays.asList(taskIds));
    
    for(int i=0; i< jsonEntries.size(); i++) 
    {
        JSONObject entry = (JSONObject) ((JSONObject)jsonEntries.get(i)).get("entry");
        assertNotNull(entry);
        String taskId = (String) entry.get("id");
        tasksToFind.remove(taskId);
    }
    assertEquals("Not all tasks have been found in query response, missing: " + StringUtils.join(tasksToFind, ","), 
                0, tasksToFind.size());
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:23,代码来源:TaskWorkflowApiTest.java

示例3: parseGroupMembers

import org.json.simple.JSONArray; //导入方法依赖的package包/类
public static ListResponse<GroupMember> parseGroupMembers(JSONObject jsonObject)
{
    List<GroupMember> groupMembers = new ArrayList<>();

    JSONObject jsonList = (JSONObject) jsonObject.get("list");
    assertNotNull(jsonList);

    JSONArray jsonEntries = (JSONArray) jsonList.get("entries");
    assertNotNull(jsonEntries);

    for (int i = 0; i < jsonEntries.size(); i++)
    {
        JSONObject jsonEntry = (JSONObject) jsonEntries.get(i);
        JSONObject entry = (JSONObject) jsonEntry.get("entry");
        groupMembers.add(parseGroupMember(entry));
    }

    ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);
    ListResponse<GroupMember> resp = new ListResponse<>(paging, groupMembers);
    return resp;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:22,代码来源:GroupMember.java

示例4: search

import org.json.simple.JSONArray; //导入方法依赖的package包/类
public List<DockerRegistryImage> search(String searchTerm) {
    // the api does not allow this TAG and DIGEST separator characters
    if (searchTerm.contains(":") || searchTerm.contains("@")) { // NOI18N
        return Collections.emptyList();
    }

    try {
        JSONArray value = (JSONArray) doGetRequest(
                "/images/search?term=" + HttpUtils.encodeParameter(searchTerm),
                Collections.singleton(HttpURLConnection.HTTP_OK));
        List<DockerRegistryImage> ret = new ArrayList<>(value.size());
        for (Object o : value) {
            JSONObject json = (JSONObject) o;
            String name = (String) json.get("name");
            String description = (String) json.get("description");
            long stars = ((Number) getOrDefault(json, "star_count", 0)).longValue();
            boolean official = (boolean) getOrDefault(json, "is_official", false);
            boolean automated = (boolean) getOrDefault(json, "is_automated", false);
            ret.add(new DockerRegistryImage(name, description, stars, official, automated));
        }
        return ret;
    } catch (DockerException | UnsupportedEncodingException ex) {
        LOGGER.log(Level.INFO, null, ex);
    }
    return Collections.emptyList();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:DockerAction.java

示例5: deleteNPC

import org.json.simple.JSONArray; //导入方法依赖的package包/类
public static void deleteNPC(String name) {
    try {
        File file = plugin.getPath().getAbsoluteFile();
        JSONParser parser = new JSONParser();
        Object parsed = parser.parse(new FileReader(file.getPath()));
        JSONObject jsonObject = (JSONObject) parsed;
        JSONArray npcsArray = (JSONArray) jsonObject.get("npcs");
        JSONObject npcObject = (JSONObject) jsonObject.get("");
        for (int i = 0; i < npcsArray.size(); i++) {
            JSONObject a = (JSONObject) npcsArray.get(i);
            if (a.get("name") == name) {
                npcsArray.remove(a);
                break;
            }
        }

    } catch (ParseException | IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:Warvale,项目名称:Locked,代码行数:21,代码来源:MerchantManager.java

示例6: parseMemberOfSites

import org.json.simple.JSONArray; //导入方法依赖的package包/类
public static ListResponse<MemberOfSite> parseMemberOfSites(JSONObject jsonObject)
{
	List<MemberOfSite> siteMembers = new ArrayList<MemberOfSite>();

	JSONObject jsonList = (JSONObject)jsonObject.get("list");
	assertNotNull(jsonList);

	JSONArray jsonEntries = (JSONArray)jsonList.get("entries");
	assertNotNull(jsonEntries);

	for(int i = 0; i < jsonEntries.size(); i++)
	{
		JSONObject jsonEntry = (JSONObject)jsonEntries.get(i);
		JSONObject entry = (JSONObject)jsonEntry.get("entry");
		siteMembers.add(parseMemberOfSite(entry));
	}
	
	ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);

	ListResponse<MemberOfSite> resp = new ListResponse<MemberOfSite>(paging, siteMembers);
	return resp;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:23,代码来源:MemberOfSite.java

示例7: parseNodeRatings

import org.json.simple.JSONArray; //导入方法依赖的package包/类
public static ListResponse<NodeRating> parseNodeRatings(String nodeId, JSONObject jsonObject)
{
	List<NodeRating> nodeRatings = new ArrayList<NodeRating>();

	JSONObject jsonList = (JSONObject)jsonObject.get("list");
	assertNotNull(jsonList);

	JSONArray jsonEntries = (JSONArray)jsonList.get("entries");
	assertNotNull(jsonEntries);

	for(int i = 0; i < jsonEntries.size(); i++)
	{
		JSONObject jsonEntry = (JSONObject)jsonEntries.get(i);
		JSONObject entry = (JSONObject)jsonEntry.get("entry");
		nodeRatings.add(NodeRating.parseNodeRating(nodeId, entry));
	}

	ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);

	ListResponse<NodeRating> resp = new ListResponse<NodeRating>(paging, nodeRatings);
	return resp;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:23,代码来源:NodeRating.java

示例8: parseSiteMembershipRequests

import org.json.simple.JSONArray; //导入方法依赖的package包/类
public static ListResponse<SiteMembershipRequest> parseSiteMembershipRequests(String username, JSONObject jsonObject) throws ParseException
{
	List<SiteMembershipRequest> siteMembershipRequests = new ArrayList<SiteMembershipRequest>();

	JSONObject jsonList = (JSONObject)jsonObject.get("list");
	assertNotNull(jsonList);

	JSONArray jsonEntries = (JSONArray)jsonList.get("entries");
	assertNotNull(jsonEntries);

	for(int i = 0; i < jsonEntries.size(); i++)
	{
		JSONObject jsonEntry = (JSONObject)jsonEntries.get(i);
		JSONObject entry = (JSONObject)jsonEntry.get("entry");
		siteMembershipRequests.add(SiteMembershipRequest.parseSiteMembershipRequest(username, entry));
	}

	ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);
	return new ListResponse<SiteMembershipRequest>(paging, siteMembershipRequests);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:21,代码来源:SiteMembershipRequest.java

示例9: getNextBlocks

import org.json.simple.JSONArray; //导入方法依赖的package包/类
private JSONArray getNextBlocks(Peer peer, long curBlockId) {

			JSONObject request = new JSONObject();
			request.put("requestType", "getNextBlocks");
			request.put("blockId", Convert.toUnsignedLong(curBlockId));
			JSONObject response = peer.send(JSON.prepareRequest(request));
			if (response == null) {
				return null;
			}

			JSONArray nextBlocks = (JSONArray) response.get("nextBlocks");
			if (nextBlocks == null) {
				return null;
			}
			// prevent overloading with blocks
			if (nextBlocks.size() > 1440) {
				Logger.logDebugMessage("Obsolete or rogue peer " + peer.getPeerAddress() + " sends too many nextBlocks, blacklisting");
				peer.blacklist();
				return null;
			}

			return nextBlocks;

		}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:25,代码来源:BlockchainProcessorImpl.java

示例10: processPendingResponses

import org.json.simple.JSONArray; //导入方法依赖的package包/类
synchronized void processPendingResponses(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    JSONArray responses = new JSONArray();
    JSONStreamAware pendingResponse;
    while ((pendingResponse = pendingResponses.poll()) != null) {
        responses.add(pendingResponse);
    }
    if (responses.size() > 0) {
        JSONObject combinedResponse = new JSONObject();
        combinedResponse.put("responses", responses);
        if (asyncContext != null) {
            asyncContext.getResponse().setContentType("text/plain; charset=UTF-8");
            try (Writer writer = asyncContext.getResponse().getWriter()) {
                combinedResponse.writeJSONString(writer);
            }
            asyncContext.complete();
            asyncContext = req.startAsync();
            asyncContext.addListener(new UserAsyncListener());
            asyncContext.setTimeout(5000);
        } else {
            resp.setContentType("text/plain; charset=UTF-8");
            try (Writer writer = resp.getWriter()) {
                combinedResponse.writeJSONString(writer);
            }
        }
    } else {
        if (asyncContext != null) {
            asyncContext.getResponse().setContentType("text/plain; charset=UTF-8");
            try (Writer writer = asyncContext.getResponse().getWriter()) {
                JSON.emptyJSON.writeJSONString(writer);
            }
            asyncContext.complete();
        }
        asyncContext = req.startAsync();
        asyncContext.addListener(new UserAsyncListener());
        asyncContext.setTimeout(5000);
    }
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:38,代码来源:User.java

示例11: parseGroups

import org.json.simple.JSONArray; //导入方法依赖的package包/类
public static ListResponse<Group> parseGroups(JSONObject jsonObject)
{
    List<Group> groups = new ArrayList<>();

    JSONObject jsonList = (JSONObject) jsonObject.get("list");
    assertNotNull(jsonList);

    JSONArray jsonEntries = (JSONArray) jsonList.get("entries");
    assertNotNull(jsonEntries);

    for (int i = 0; i < jsonEntries.size(); i++)
    {
        JSONObject jsonEntry = (JSONObject) jsonEntries.get(i);
        JSONObject entry = (JSONObject) jsonEntry.get("entry");
        groups.add(parseGroup(entry));
    }

    ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);
    ListResponse<Group> resp = new ListResponse<>(paging, groups);
    return resp;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:22,代码来源:Group.java

示例12: parseNetworkMembers

import org.json.simple.JSONArray; //导入方法依赖的package包/类
public static ListResponse<PersonNetwork> parseNetworkMembers(JSONObject jsonObject)
{
	List<PersonNetwork> networkMembers = new ArrayList<PersonNetwork>();

	JSONObject jsonList = (JSONObject)jsonObject.get("list");
	assertNotNull(jsonList);

	JSONArray jsonEntries = (JSONArray)jsonList.get("entries");
	assertNotNull(jsonEntries);

	for(int i = 0; i < jsonEntries.size(); i++)
	{
		JSONObject jsonEntry = (JSONObject)jsonEntries.get(i);
		JSONObject entry = (JSONObject)jsonEntry.get("entry");
		networkMembers.add(PersonNetwork.parseNetworkMember(entry));
	}

	ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);
	ListResponse<PersonNetwork> resp = new ListResponse<PersonNetwork>(paging, networkMembers);
	return resp;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:22,代码来源:PersonNetwork.java

示例13: parseEntry

import org.json.simple.JSONArray; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public ProcessInfo parseEntry(JSONObject entry)
{
    ProcessInfo processesRest = new ProcessInfo();
    processesRest.setId((String) entry.get("id"));
    processesRest.setProcessDefinitionId((String) entry.get("processDefinitionId"));
    processesRest.setProcessDefinitionKey((String) entry.get("processDefinitionKey"));
    processesRest.setStartedAt(WorkflowApiClient.parseDate(entry, "startedAt"));
    processesRest.setEndedAt(WorkflowApiClient.parseDate(entry, "endedAt"));
    processesRest.setDurationInMs((Long) entry.get("durationInMs"));
    processesRest.setDeleteReason((String) entry.get("deleteReason"));
    processesRest.setBusinessKey((String) entry.get("businessKey"));
    processesRest.setSuperProcessInstanceId((String) entry.get("superProcessInstanceId"));
    processesRest.setStartActivityId((String) entry.get("startActivityId"));
    processesRest.setStartUserId((String) entry.get("startUserId"));
    processesRest.setEndActivityId((String) entry.get("endActivityId"));
    processesRest.setCompleted((Boolean) entry.get("completed"));
    processesRest.setVariables((Map<String,Object>) entry.get("variables"));
    processesRest.setItems((Set<String>) entry.get("item"));
    
    if (entry.get("processVariables") != null) {
        List<Variable> processVariables = new ArrayList<Variable>();
        JSONArray variables = (JSONArray) entry.get("processVariables");
        for (int i = 0; i < variables.size(); i++) 
        {
            JSONObject variableJSON = (JSONObject) variables.get(i);
            Variable variable = new Variable();
            variable.setName((String) variableJSON.get("name"));
            variable.setType((String) variableJSON.get("type"));
            variable.setValue(variableJSON.get("value"));
            processVariables.add(variable);
        }
        processesRest.setProcessVariables(processVariables);
    }
    
    return processesRest;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:39,代码来源:ProcessesParser.java

示例14: TextBound

import org.json.simple.JSONArray; //导入方法依赖的package包/类
public TextBound(AlvisAEAnnotationSet annotationSet, JSONObject json) {
	super(annotationSet, json);
	JSONArray fragments = (JSONArray) json.get("text");
	this.fragments = new Fragment[fragments.size()];
	for (int i = 0; i < this.fragments.length; ++i) {
		JSONArray f = (JSONArray) fragments.get(i);
		long start = (long) f.get(0);
		long end = (long) f.get(1);
		this.fragments[i] = new SimpleFragment((int) start, (int) end);
	}
	annotationSet.addTextBound(this);
}
 
开发者ID:Bibliome,项目名称:bibliome-java-utils,代码行数:13,代码来源:TextBound.java

示例15: getQueuedepths

import org.json.simple.JSONArray; //导入方法依赖的package包/类
public HashMap<String, Long> getQueuedepths(){
	JSONArray queues = getQueueDetails();
	HashMap<String, Long> hash = new HashMap<String, Long>();
	try{
		for(int i=0; i<queues.size(); i++)
			hash.put((String)((JSONObject)queues.get(i)).get("name"), (Long)((JSONObject)queues.get(i)).get("messages"));
	}
	catch(Exception e){
		e.printStackTrace();
	}
	return hash;
}
 
开发者ID:hemantverma1,项目名称:ServerlessPlatform,代码行数:13,代码来源:communicateWithMQ.java


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