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


Java JSONObject.get方法代码示例

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


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

示例1: createIssue

import org.json.simple.JSONObject; //导入方法依赖的package包/类
@Override
public synchronized String createIssue(JSONObject issue, List<File> attach) {
    String result = "[JIRA : Issue Creation Failed!!]\n";
    try {
        JSONObject res = restClient.createIssue(issue, attach);
        Object key = res.get("key");
        if (key != null) {
            result = "[JIRA : Issue " + key + " Created successfully!!]";
        }
    } catch (Exception ex) {
        LOG.log(Level.SEVERE, ex.getMessage(), ex);
        result += ex.getMessage();
    }

    return result;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:17,代码来源:JIRASync.java

示例2: parseComments

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

	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");
		comments.add(Comment.parseComment(nodeId, entry));
	}

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

示例3: getPrice

import org.json.simple.JSONObject; //导入方法依赖的package包/类
public static long getPrice(int id) {
    if (prices.containsKey(id)) {
        return prices.get(id);
    } else {
        try {
            String content = WebUtil.getContents(Configuration.ITEM_API + id + "/" + Context.getInstance().getServerProviderInfo().getServerName());
            if (content.length() > 0) {
                JSONObject jsonObject      = (JSONObject) jsonParser.parse(content);
                JSONObject itemInformation = (JSONObject) jsonObject.get("result");
                if (itemInformation.get("price") != null && !((String) itemInformation.get("price")).equalsIgnoreCase("null")) {
                    long price = Long.parseLong((String) itemInformation.get("price"));
                    prices.put(id, price);
                    return price;
                }
            }
        } catch (MalformedURLException | ParseException e) {
            e.printStackTrace();
        }
    }
    return 0;
}
 
开发者ID:Parabot,项目名称:Parabot-317-API-Minified-PkHonor,代码行数:22,代码来源:Items.java

示例4: before

import org.json.simple.JSONObject; //导入方法依赖的package包/类
/**
 * 各テストを実行する前の処理.
 */
@Before
public final void before() {
    if (roleUri == null) {
        TResponse response = Http.request("role-list.txt")
                .with("token", AbstractCase.MASTER_TOKEN_NAME).with("cellPath", CELL_NAME)
                .returns().statusCode(HttpStatus.SC_OK);
        JSONObject d = (JSONObject) response.bodyAsJson().get("d");
        JSONArray results = (JSONArray) d.get("results");
        String name = (String) ((JSONObject) results.get(0)).get("Name");
        String boxName = (String) ((JSONObject) results.get(0)).get("_Box.Name");
        if (boxName == null) {
            roleKey = "Name='" + name + "',_Box.Name=null";
        } else {
            roleKey = "Name='" + name + "',_Box.Name='" + boxName + "'";
        }
        roleUri = UrlUtils.cellCtlWithoutSingleQuote(CELL_NAME, ENTITY_SET_ROLE, roleKey);
    }
}
 
开发者ID:personium,项目名称:personium-core,代码行数:22,代码来源:ExtCellLinkTest.java

示例5: parseActivities

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

	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");
		activities.add(Activity.parseActivity(entry));
	}

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

示例6: createExtRole

import org.json.simple.JSONObject; //导入方法依赖的package包/类
/**
 * 30_$extroles.jsonに定義されているExtRole情報をESへ登録する.
 * @param json JSONファイルから読み込んだJSONオブジェクト
 */
@SuppressWarnings("unchecked")
private void createExtRole(JSONObject json) {
    String url = (String) json.get(ExtRole.EDM_TYPE_NAME);
    json.put(ExtRole.EDM_TYPE_NAME, url);
    json.put("_Relation._Box.Name", createdBoxName);
    StringReader stringReader = new StringReader(json.toJSONString());

    odataEntityResource.setEntitySetName(ExtRole.EDM_TYPE_NAME);
    OEntityWrapper oew = odataEntityResource.getOEntityWrapper(stringReader,
            odataEntityResource.getOdataResource(),
            CtlSchema.getEdmDataServicesForCellCtl().build());

    // ExtRoleの登録
    odataProducer.
            createEntity(ExtRole.EDM_TYPE_NAME, oew);
}
 
开发者ID:personium,项目名称:personium-core,代码行数:21,代码来源:BarFileReadRunner.java

示例7: setRuleSelector

import org.json.simple.JSONObject; //导入方法依赖的package包/类
/**
 * Sets the selector of a rule.
 *
 * @param ruleId ID of the rule to modify.
 * @param selector new selector of the rule.
 * @return the resulting rule after the selector modification.
 */
public Rule setRuleSelector(RuleId ruleId, String selector) {
    Rule resultingRule = null;
    JSONObject params = new JSONObject();
    params.put("ruleId", ruleId.toJSONObject()); // NOI18N
    params.put("selector", selector); // NOI18N
    Response response = transport.sendBlockingCommand(new Command("CSS.setRuleSelector", params)); // NOI18N
    if (response != null) {
        JSONObject result = response.getResult();
        if (result != null) {
            JSONObject rule = (JSONObject)result.get("rule"); // NOI18N
            resultingRule = new Rule(rule);
        }
    }
    return resultingRule;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:CSS.java

示例8:

import org.json.simple.JSONObject; //导入方法依赖的package包/类
/**
 * 昇格設定のないアカウントがリフレッシュトークン認証でユニットローカルユニットユーザトークンへ昇格できないことの確認. setupのtestcell1がある前提.
 * @throws TokenParseException トークンパースエラー
 */
@Test
@Ignore // UUT promotion setting API invalidation.
public final void 昇格設定のないアカウントがリフレッシュトークン認証でユニットローカルユニットユーザトークンへ昇格できないことの確認() throws TokenParseException {
    // 認証(パスワード認証)
    TResponse res = Http.request("authn/password-cl-c0.txt")
            .with("remoteCell", Setup.TEST_CELL1)
            .with("username", "account3")
            .with("password", "password3")
            .returns()
            .statusCode(HttpStatus.SC_OK);

    JSONObject json = res.bodyAsJson();
    String refresh = (String) json.get(OAuth2Helper.Key.REFRESH_TOKEN);

    // アカウントにユニット昇格権限付与
    DavResourceUtils.setProppatch(Setup.TEST_CELL1, AbstractCase.MASTER_TOKEN_NAME,
            "cell/proppatch-uluut.txt", HttpStatus.SC_MULTI_STATUS);

    // リフレッシュ認証でのユニット昇格してみる(account1、account2は許可権限あるけどaccount3にはない)
    Http.request("authnUnit/refresh-uluut.txt")
            .with("remoteCell", Setup.TEST_CELL1)
            .with("refresh_token", refresh)
            .returns()
            .statusCode(HttpStatus.SC_BAD_REQUEST);
}
 
开发者ID:personium,项目名称:personium-core,代码行数:30,代码来源:UnitUserCellCRUDTest.java

示例9: getAllNPCs

import org.json.simple.JSONObject; //导入方法依赖的package包/类
public static ArrayList<String> getAllNPCs() {
    ArrayList<String> a = new ArrayList<>();
    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");
        for (Object npc : npcsArray) {
            a.add((String) ((JSONObject) npc).get("name"));

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

示例10: getTestCaseId

import org.json.simple.JSONObject; //导入方法依赖的package包/类
/**
 * 
 * @param testcase
 * @param client
 * @return 
 */
private int getTestCaseId(String testcase, ZephyrHttpClient client) {
    int tcaseId = -1;
    try {
        String url = client.url + TCASEID + "?testcase.name=" + URLEncoder.encode(testcase, "UTF-8");
        DLogger.Log("Req Testcase ID ", url);
        JSONObject releaseList = client.Get(new URL(url));
        DLogger.Log("Looking for [", testcase, "] in", releaseList);
        for (Object proj : (Iterable<? extends Object>) releaseList
                .get("array")) {
            JSONObject tcaseObj = (JSONObject) ((JSONObject) proj).get(ZephyrClient.array.TESTCASE);
            tcaseId = Integer.valueOf(tcaseObj.get(ZephyrClient.array.ID).toString());
            if (tcaseId == -1) {
                DLogger.LogE("Testcase [", testcase, "] not found");
            }
        }
    } catch (Exception ex) {
        Logger.getLogger(ZephyrClient.class.getName()).log(Level.SEVERE, null, ex);
    }
    return tcaseId;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:27,代码来源:ZephyrClient.java

示例11: parseEntry

import org.json.simple.JSONObject; //导入方法依赖的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

示例12: receiveGET

import org.json.simple.JSONObject; //导入方法依赖的package包/类
/**
 * Implemented receiveGET from Interface interfaceAPI (see for more details)
 *
 * @throws IOException
 *             IO Error
 * @throws ParseException
 *             Parse Error
 */
@Override
public void receiveGET() throws IOException, ParseException {
	JSONArray JSONArray = readResponseJSON(API_IDENTIFIER, EntityUtils.toString(httpEntity, "UTF-8"), "entities");

	if (JSONArray != null) {
		for (Object aJSONArray : JSONArray) {

			JSONObject object = (JSONObject) aJSONArray;
			ResponseEntry entity = new ResponseEntry();

			String s = (String) object.get("text");
			s = addEntity(s);

			// Add Entity only if it is new and has not been added before
			if (s != null) {
				entity.setEntry(s);
				entity.setConfidence(convertRelevance((String) object.get("relevance")));
				foundEntryList.add(entity);
			}
		}

		// Sort the Array List Entities from A to Z
		Collections.sort(foundEntryList, new SortResponseEntity());
		int i = 1;
		for (ResponseEntry e : foundEntryList) {
			LOG.debug("Entity " + i + " is " + e.getEntry() + "(" + e.getConfidence() + ")");
			i++;
		}
	}
}
 
开发者ID:CCWI,项目名称:keywordEntityApiRankService,代码行数:39,代码来源:AlchemyEntityAPI.java

示例13: parsePreference

import org.json.simple.JSONObject; //导入方法依赖的package包/类
public static Preference parsePreference(JSONObject jsonObject)
{
	String id = (String)jsonObject.get("id");
	String value = jsonObject.get("value").toString();
	Preference preference = new Preference(id, value);
	return preference;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:8,代码来源:Preference.java

示例14: apply

import org.json.simple.JSONObject; //导入方法依赖的package包/类
@Override
public JSONObject apply(final JSONObject a, final JSONObject b) {
    for (final Map.Entry entry : (Set<Map.Entry>) b.entrySet()) {
        if (entry.getValue() instanceof JSONObject) {
            if (a.containsKey(entry.getKey())) {
                final Object object = a.get(entry.getKey());
                if (object instanceof JSONArray) {
                    final JSONObject other = findById((JSONArray) object, ((JSONObject) entry.getValue()));
                    if (null == other)
                        ((JSONArray) object).add(format((JSONObject) entry.getValue()));
                    else
                        apply(other, (JSONObject) entry.getValue());
                } else {
                    final JSONArray array = new JSONArray();
                    array.add(object);
                    array.add(format((JSONObject) entry.getValue()));
                    a.put(entry.getKey(), array);
                }
            } else
                a.put(entry.getKey(), format((JSONObject) entry.getValue()));

        } else if (entry.getValue() instanceof List)
            a.put(entry.getKey(),
                    ((List) entry.getValue()).size() == 1 ?
                            ((List) entry.getValue()).get(0) : entry.getValue());
        else
            a.put(entry.getKey(), entry.getValue());
    }
    return a;
}
 
开发者ID:okram,项目名称:mongodb-gremlin,代码行数:31,代码来源:MongoDBQueryStep.java

示例15: addObjectInformationIntoCollections

import org.json.simple.JSONObject; //导入方法依赖的package包/类
/**
 * This function adds <uid,name> of a given object to the collection, and adds the object to the objects File.
 *
 * @param object the object that will be added
 */
private static void addObjectInformationIntoCollections(JSONObject object){

    String uid = object.get("uid").toString();
    if (!configuration.getUidToName().containsKey(uid)) {
        //If the object doesn't already exist in the collection
        String name = "";
        if(object.containsKey("name") && object.get("name") != null ){
            name = object.get("name").toString();
        }
        configuration.getUidToName().put(uid, name);
        writeJSonObjectToFile(object, configuration.getObjectsWriter(), false);
    }
}
 
开发者ID:CheckPoint-APIs-Team,项目名称:ShowPolicyPackage,代码行数:19,代码来源:ShowPackageTool.java


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