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


Java JSONArray.get方法代码示例

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


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

示例1: resolveOperatorInputPortNames

import org.json.simple.JSONArray; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void resolveOperatorInputPortNames(JSONObject operator) {
	JSONArray inputPortArray = (JSONArray) operator.get("inputPorts");

	if (inputPortArray == null) {
		return;
	}

	String operatorName = getOperatorName(operator);
	Map<Integer, String> inputPortNames = operatorInputPortNames.get(operatorName);

	if (inputPortNames == null) {
		return;
	}

	for (int i = 0; i < inputPortArray.size(); i++) {
		JSONObject inputPort = (JSONObject) inputPortArray.get(i);
		int portIndex = getOperatorPortIndex(inputPort);
		String portName = inputPortNames.get(portIndex);

		if (portName != null) {
			inputPort.put("name", portName);
		}
	}
}
 
开发者ID:IBMStreams,项目名称:streamsx.jmxclients,代码行数:26,代码来源:JobDetails.java

示例2: convertJSONArrayToMessage

import org.json.simple.JSONArray; //导入方法依赖的package包/类
private static Message convertJSONArrayToMessage(JSONArray ja, Class c, Registry<Class> r) {
    try {
        Message result = (Message) c.newInstance();
        int arrayIndex = 0;
        for (Field f : c.getFields()) {
            Class fc = getFieldClass(result, null, f, r);
            Object lookup = ja.get(arrayIndex++);         // yes we are assuming that the fields are delivered in order
            if (lookup != null) {
                Object value = convertElementToField(lookup, fc, f, r);
                f.set(result, value);
            }
        }
        
        return result;
    }
    catch (Exception ex) {
        ex.printStackTrace();
        return null;
    }        
}
 
开发者ID:lazyparser,项目名称:xbot_head,代码行数:21,代码来源:JSON.java

示例3: getController

import org.json.simple.JSONArray; //导入方法依赖的package包/类
private String getController(String topologyFile) throws Exception {
    ClassLoader classLoader = getClass().getClassLoader();
    URL resource = classLoader.getResource(topologyFile);
    if (resource == null) {
        throw new IllegalArgumentException(String.format("No such topology json file: %s", topologyFile));
    }

    File file = new File(resource.getFile());
    String json = new String(Files.readAllBytes(file.toPath()));
    JSONParser parser = new JSONParser();
    JSONObject jsonObject = (JSONObject) parser.parse(json);
    JSONArray controllers = (JSONArray) jsonObject.get("controllers");

    JSONObject controller = (JSONObject) controllers.get(0);
    return  (String) controller.get("host");
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:17,代码来源:FlowFFRTest.java

示例4: process

import org.json.simple.JSONArray; //导入方法依赖的package包/类
private JSONArray process(JSONArray arr, int room) throws SQLException {
	HashMap<Integer, String> map = getSeatDatas(room);
	int count = 1;
	for (int i = 0; i < arr.size(); i++) {
		JSONArray row = (JSONArray) arr.get(i);
		for (int k = 0; k < row.size(); k++) {
			if (((long) row.get(k)) == 1) {
				row.remove(k);
				if (map.get(count) != null) {
					row.add(k, map.get(count));
				} else {
					row.add(k, count);
				}
				count++;
			}
		}
	}
	return arr;
}
 
开发者ID:DSM-DMS,项目名称:DMS,代码行数:20,代码来源:LoadExtensionClassStatus.java

示例5: 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

示例6: 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

示例7: parseAuditEntries

import org.json.simple.JSONArray; //导入方法依赖的package包/类
public static ListResponse<AuditEntry> parseAuditEntries(JSONObject jsonObject)
{
    List<AuditEntry> entries = 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");
        entries.add(parseAuditEntry(entry));
    }

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

示例8: parsePeople

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

    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");
        people.add(parsePerson(entry));
    }

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

示例9: convertJSONArrayToArray

import org.json.simple.JSONArray; //导入方法依赖的package包/类
private static Object convertJSONArrayToArray(JSONArray ja, Class c, Registry<Class> r) {
    Object result = Array.newInstance(c, ja.size());
    for (int i = 0; i < ja.size(); i++) {
        Object lookup = ja.get(i);
        Object value = null;
        if (lookup != null) {
            if (lookup.getClass().equals(JSONObject.class))
                value = convertJSONObjectToMessage((JSONObject) lookup, c, r);
            else if (lookup.getClass().equals(JSONArray.class))  // this is not actually allowed in ROS
                value = convertJSONArrayToArray((JSONArray) lookup, c.getComponentType(), r);
            else 
                value = convertJSONPrimitiveToPrimitive(lookup, c);
            Array.set(result, i, value);
        }
    }
    
    return result;
}
 
开发者ID:lazyparser,项目名称:xbot_head,代码行数:19,代码来源:JSON.java

示例10: Room

import org.json.simple.JSONArray; //导入方法依赖的package包/类
/**
 * Use JSON.simple to create a room from a JSONObject.
 * NOTE: Assumes the object IS a room!
 * @param jsonroom a JSONObject containing a room.
 */
public Room(JSONObject jsonroom) {
    try {
        JSONObject jlocation = (JSONObject)jsonroom.get("location");
        JSONObject jcoordinates = (JSONObject)jlocation.get("coordinates");
        JSONArray jaddress = (JSONArray)jlocation.get("address");

        this.roomname = new String(((String)jsonroom.get("roomname")));
        this.roomid = new String(((String)jsonroom.get("roomid")));
        this.siteid = new String(((String)jsonroom.get("siteid")));
        this.sitename = new String(((String)jsonroom.get("sitename")));
        this.capacity = ((long)jsonroom.get("capacity"));
        this.classification = new String(((String)jsonroom.get("classification")));
        this.automated = new String(((String)jsonroom.get("automated")));

        this.latitude = Double.parseDouble((String)jcoordinates.get("lat"));
        this.longitude = Double.parseDouble((String)jcoordinates.get("lng"));

        this.address = new String[address_size];
        for (int i = 0; i < address_size; i++) {
            this.address[i] = new String((String)jaddress.get(i));
        }

    } catch(Exception e) {
        System.err.println(e.toString());
        if (uclapi.UCLApiConnection.ExitOnException) {
            System.exit(2);
        }
    }

}
 
开发者ID:owainkenwayucl,项目名称:uclapi-java,代码行数:36,代码来源:Room.java

示例11: deleteReceivedMessage

import org.json.simple.JSONArray; //导入方法依赖的package包/类
/**
 * 自動生成された受信メッセージの削除.
 * @param targetCell targetCell
 * @param fromCellUrl fromCellUrl
 * @param type type
 * @param title title
 * @param body body
 */
public static void deleteReceivedMessage(String targetCell,
        String fromCellUrl,
        String type,
        String title,
        String body) {
    TResponse resReceivedList = null;
    try {
        resReceivedList = Http
                .request("received-message-list.txt")
                .with("cellPath", targetCell)
                .with("token", AbstractCase.MASTER_TOKEN_NAME)
                .with("query", "?\\$filter=From+eq+%27" + URLEncoder.encode(fromCellUrl, "UTF-8") + "%27+"
                        + "and+Type+eq+%27" + URLEncoder.encode(type, "UTF-8") + "%27+"
                        + "and+Title+eq+%27" + URLEncoder.encode(title, "UTF-8") + "%27")
                .returns()
                .debug();
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    JSONObject jsonBody = (JSONObject) resReceivedList.bodyAsJson().get("d");
    if (jsonBody != null) {
        JSONArray resultsList = (JSONArray) jsonBody.get("results");
        for (int i = 0; i < resultsList.size(); i++) {
            JSONObject results = (JSONObject) resultsList.get(i);
            String id = (String) results.get("__id");
            ReceivedMessageUtils.delete(AbstractCase.MASTER_TOKEN_NAME, targetCell, -1, id);
        }
    }
}
 
开发者ID:personium,项目名称:personium-core,代码行数:38,代码来源:SentMessageUtils.java

示例12: MessagingHubAnnouncement

import org.json.simple.JSONArray; //导入方法依赖的package包/类
MessagingHubAnnouncement(JSONObject attachmentData) throws NxtException.NotValidException {
    super(attachmentData);
    this.minFeePerByteNQT = (Long) attachmentData.get("minFeePerByte");
    try {
        JSONArray urisData = (JSONArray) attachmentData.get("uris");
        this.uris = new String[urisData.size()];
        for (int i = 0; i < uris.length; i++) {
            uris[i] = (String) urisData.get(i);
        }
    } catch (RuntimeException e) {
        throw new NxtException.NotValidException("Error parsing hub terminal announcement parameters", e);
    }
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:14,代码来源:Attachment.java

示例13: assertEquals

import org.json.simple.JSONArray; //导入方法依赖的package包/类
/**
 * EntityTypeからNP経由でAssociationEndを登録できること.
 * @throws ParseException パースエラー
 */
@Test
public final void EntityTypeからNP経由でAssociationEndを登録できること() throws ParseException {
    String entityType1 = "AssociationEndTestEntity1";

    String assocEntity1of1 = "AssociationEndTestEntity1-1";

    try {
        // EntityType作成
        EntityTypeUtils.create(Setup.TEST_CELL1, MASTER_TOKEN_NAME, Setup.TEST_BOX1, Setup.TEST_ODATA,
                entityType1, HttpStatus.SC_CREATED);

        // AssociationEnd NP経由登録
        AssociationEndUtils.createViaEntityTypeNP(
                MASTER_TOKEN_NAME, Setup.TEST_CELL1, Setup.TEST_BOX1, Setup.TEST_ODATA,
                assocEntity1of1, "*", entityType1, HttpStatus.SC_CREATED);

        // AssociationEndの EntityTypeからのNP経由一覧取得
        TResponse res = AssociationEndUtils.listViaAssociationEndNP(MASTER_TOKEN_NAME, Setup.TEST_CELL1,
                Setup.TEST_BOX1, Setup.TEST_ODATA, "EntityType", entityType1, HttpStatus.SC_OK);
        JSONArray results = (JSONArray) ((JSONObject) res.bodyAsJson().get("d")).get("results");
        assertEquals(1, results.size());
        JSONObject body = (JSONObject) results.get(0);
        assertEquals(assocEntity1of1, body.get("Name"));

    } finally {
        // AssociationEndの削除
        AssociationEndUtils.delete(AbstractCase.MASTER_TOKEN_NAME, Setup.TEST_CELL1, Setup.TEST_ODATA, entityType1,
                Setup.TEST_BOX1, assocEntity1of1, -1);

        // EntityTypeの削除
        EntityTypeUtils.delete(Setup.TEST_ODATA, MASTER_TOKEN_NAME, MediaType.APPLICATION_JSON,
                entityType1, Setup.TEST_BOX1, Setup.TEST_CELL1, -1);
    }
}
 
开发者ID:personium,项目名称:personium-core,代码行数:39,代码来源:AssociationEndCreateViaNPTest.java

示例14: searchAPI

import org.json.simple.JSONArray; //导入方法依赖的package包/类
/**
 * Perform a query on a given UCL API connection and return an array of people.
 * @param conn UCLApiConnection
 * @param query Query string
 * @return Array of people
 */
public static Person[] searchAPI(UCLApiConnection conn, String query) {
    Hashtable<String, String> params = new Hashtable<String, String>();
    params.put("query", query);
    String response = conn.queryAPI(UCLApiConnection.SearchPeopleEP, params);

    try {
        JSONParser p = new JSONParser();
        JSONObject responseObject = (JSONObject)p.parse(response);

        JSONArray people = (JSONArray)responseObject.get("people");
        int nPeople = people.size();
        Person[] retval = new Person[nPeople];

        for (int i = 0; i < nPeople; i++) {
            JSONObject jperson = (JSONObject)people.get(i);

            retval[i] = new Person(jperson);

        }
        return retval;
    } catch (Exception e){
        System.err.println(e.toString());
        if (uclapi.UCLApiConnection.ExitOnException) {
            System.exit(5);
        }
    }
    return new Person[0];
}
 
开发者ID:owainkenwayucl,项目名称:uclapi-java,代码行数:35,代码来源:Person.java

示例15: searchAPI

import org.json.simple.JSONArray; //导入方法依赖的package包/类
/**
 * Perform a query on a given UCL API connection and return an array of rooms.
 * @param conn UCLApiConnection
 * @param endpoint the API path
 * @param params hashtable of query parameters
 * @return Array of Rooms
 */
public static Room[] searchAPI(UCLApiConnection conn, String endpoint, Hashtable<String, String> params) {
    String response = conn.queryAPI(endpoint, params);

    try {
        JSONParser p = new JSONParser();
        JSONObject responseObject = (JSONObject)p.parse(response);

        JSONArray rooms = (JSONArray)responseObject.get("rooms");
        int nRooms = rooms.size();
        Room[] retval = new Room[nRooms];

        for (int i = 0; i < nRooms; i++) {
            JSONObject jroom = (JSONObject)rooms.get(i);

            retval[i] = new Room(jroom);

        }

        return retval;

    } catch (Exception e){
        System.err.println(e.toString());
        if (uclapi.UCLApiConnection.ExitOnException) {
            System.exit(5);
        }
    }
    return new Room[0];
}
 
开发者ID:owainkenwayucl,项目名称:uclapi-java,代码行数:36,代码来源:Room.java


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