本文整理匯總了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;
}
示例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);
}
示例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;
}
示例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);
}
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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++;
}
}
}
示例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;
}
示例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;
}
示例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);
}
}