org.codehaus.jettison.json.JSONObject.getInt()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(91)

本文整理了Java中org.codehaus.jettison.json.JSONObject.getInt()方法的一些代码示例,展示了JSONObject.getInt()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONObject.getInt()方法的具体详情如下:
包路径:org.codehaus.jettison.json.JSONObject
类名称:JSONObject
方法名:getInt

JSONObject.getInt介绍

[英]Get the int value associated with a key. If the number value is too large for an int, it will be clipped.
[中]获取与键关联的int值。如果数值对于int太大,则将对其进行剪裁。

代码示例

代码示例来源:origin: apache/nifi

while (newSessionInfo.getString("state").equalsIgnoreCase("starting")) {
  log.debug("openSession() Waiting for session to start...");
  newSessionInfo = getSessionInfo(newSessionInfo.getInt("id"));
  log.debug("openSession() newSessionInfo: " + newSessionInfo);
  Thread.sleep(1000);

代码示例来源:origin: apache/nifi

private Map<Integer, JSONObject> listSessions() throws IOException {
  String sessionsUrl = livyUrl + "/sessions";
  int numSessions;
  JSONObject sessionsInfo;
  Map<Integer, JSONObject> sessionsMap = new HashMap<>();
  Map<String, String> headers = new HashMap<>();
  headers.put("Content-Type", APPLICATION_JSON);
  headers.put("X-Requested-By", USER);
  try {
    sessionsInfo = readJSONFromUrl(sessionsUrl, headers);
    numSessions = sessionsInfo.getJSONArray("sessions").length();
    for (int i = 0; i < numSessions; i++) {
      int currentSessionId = sessionsInfo.getJSONArray("sessions").getJSONObject(i).getInt("id");
      JSONObject currentSession = sessionsInfo.getJSONArray("sessions").getJSONObject(i);
      sessionsMap.put(currentSessionId, currentSession);
    }
  } catch (JSONException e) {
    throw new IOException(e);
  }
  return sessionsMap;
}

代码示例来源:origin: apache/nifi

for (int i = 0; i < sessionPoolSize; i++) {
  newSessionInfo = openSession();
  sessions.put(newSessionInfo.getInt("id"), newSessionInfo);
  log.debug("manageSessions() Registered new session: " + newSessionInfo);
  log.debug("manageSessions() There are " + numSessions + " sessions in the pool but none of them are idle sessions, creating...");
  newSessionInfo = openSession();
  sessions.put(newSessionInfo.getInt("id"), newSessionInfo);
  log.debug("manageSessions() Registered new session: " + newSessionInfo);
  for (int i = 0; i < sessionPoolSize - numSessions; i++) {
    newSessionInfo = openSession();
    sessions.put(newSessionInfo.getInt("id"), newSessionInfo);
    log.debug("manageSessions() Registered new session: " + newSessionInfo);

代码示例来源:origin: apache/nifi

JSONObject jobInfo = readJSONObjectFromUrlPOST(statementUrl, livySessionService, headers, payload);
log.debug("submitAndHandleJob() Job Info: " + jobInfo);
String statementId = String.valueOf(jobInfo.getInt("id"));
statementUrl = statementUrl + "/" + statementId;
jobInfo = readJSONObjectFromUrl(statementUrl, livySessionService, headers);

代码示例来源:origin: com.atlassian.jira/jira-rest-java-client

@Override
  public Integer parse(JSONObject json) throws JSONException {
    return json.getInt("issuesUnresolvedCount");
  }
}, progressMonitor);

代码示例来源:origin: com.atlassian.jira/jira-rest-java-client-core

@Override
  public Integer parse(JSONObject json) throws JSONException {
    return json.getInt("issueCount");
  }
});

代码示例来源:origin: com.atlassian.jira/jira-rest-java-client

@Override
  public SearchResult parse(JSONObject json) throws JSONException {
    final int startAt = json.getInt("startAt");
    final int maxResults = json.getInt("maxResults");
    final int total = json.getInt("total");
    final Collection<BasicIssue> issues = JsonParseUtil.parseJsonArray(json.getJSONArray("issues"), basicIssueJsonParser);
    return new SearchResult(startAt, maxResults, total, issues);
  }
}

代码示例来源:origin: com.atlassian.jira/jira-rest-java-client-p3

@Override
  public VersionRelatedIssuesCount parse(JSONObject json) throws JSONException {
    final URI selfUri = JsonParseUtil.getSelfUri(json);
    final int issuesFixedCount = json.getInt("issuesFixedCount");
    final int issuesAffectedCount = json.getInt("issuesAffectedCount");
    return new VersionRelatedIssuesCount(selfUri, issuesFixedCount, issuesAffectedCount);
  }
}

代码示例来源:origin: batfish/batfish

public static int tryGetInt(JSONObject jsonObject, String key, int defaultValue)
  throws JSONException {
 if (jsonObject.has(key)) {
  return jsonObject.getInt(key);
 }
 return defaultValue;
}

代码示例来源:origin: ORCID/ORCID-Source

public static int extractInt(JSONObject record, String key) {
  if (record.isNull(key)) {
    return -1;
  }
  try {
    return record.getInt(key);
  } catch (JSONException e) {
    throw new RuntimeException("Error extracting int from json", e);
  }
}

代码示例来源:origin: com.atlassian.jira/jira-rest-java-client

public Transition parse(JSONObject json) throws JSONException {
  final int id = json.getInt("id");
  final String name = json.getString("name");
  final JSONObject fieldsObj = json.getJSONObject("fields");
  final Iterator keys = fieldsObj.keys();
  final Collection<Transition.Field> fields = Lists.newArrayList();
  while(keys.hasNext()) {
    final String fieldId = keys.next().toString();
    fields.add(transitionFieldJsonParser.parse(fieldsObj.getJSONObject(fieldId), fieldId));
  }
  return new Transition(name, id, fields);
}

代码示例来源:origin: com.atlassian.jira/jira-rest-java-client-p3

public Transition parse(JSONObject json) throws JSONException {
  final int id = json.getInt("id");
  final String name = json.getString("name");
  final JSONObject fieldsObj = json.getJSONObject("fields");
  final Iterator keys = fieldsObj.keys();
  final Collection<Transition.Field> fields = Lists.newArrayList();
  while(keys.hasNext()) {
    final String fieldId = keys.next().toString();
    fields.add(transitionFieldJsonParser.parse(fieldsObj.getJSONObject(fieldId), fieldId));
  }
  return new Transition(name, id, fields);
}

代码示例来源:origin: org.openengsb.wrapped/jira-rest-java-client-core

@Override
  public BasicVotes parse(JSONObject json) throws JSONException {
    final URI self = JsonParseUtil.getSelfUri(json);
    final int voteCount = json.getInt("votes");
    final boolean hasVoted = json.getBoolean("hasVoted");
    return new BasicVotes(self, voteCount, hasVoted);
  }
}

代码示例来源:origin: batfish/batfish

public VgwTelemetry(JSONObject jObj) throws JSONException {
 _status = jObj.getString(AwsVpcEntity.JSON_KEY_STATUS);
 _statusMessage = jObj.getString(AwsVpcEntity.JSON_KEY_STATUS_MESSAGE);
 _acceptedRouteCount = jObj.getInt(AwsVpcEntity.JSON_KEY_ACCEPTED_ROUTE_COUNT);
 _outsideIpAddress = Ip.parse(jObj.getString(AwsVpcEntity.JSON_KEY_OUTSIDE_IP_ADDRESS));
}

代码示例来源:origin: com.atlassian.jira/jira-rest-java-client

@Override
  public LoginInfo parse(JSONObject json) throws JSONException {
    final int failedLoginCount = json.optInt("failedLoginCount");
    final int loginCount = json.getInt("loginCount");
    final DateTime lastFailedLoginTime = JsonParseUtil.parseOptionalDateTime(json, "lastFailedLoginTime");
    final DateTime previousLoginTime = JsonParseUtil.parseOptionalDateTime(json, "previousLoginTime");
    return new LoginInfo(failedLoginCount, loginCount, lastFailedLoginTime, previousLoginTime);
  }
}

代码示例来源:origin: org.openengsb.wrapped/jira-rest-java-client-core

@Override
  public Permission parse(final JSONObject json) throws JSONException {
    final Integer id = json.getInt("id");
    final String key = json.getString("key");
    final String name = json.getString("name");
    final String description = json.getString("description");
    final boolean havePermission = json.getBoolean("havePermission");
    return new Permission(id, key, name, description, havePermission);
  }
}

代码示例来源:origin: org.openengsb.wrapped/jira-rest-java-client-core

@Override
  public ServerInfo parse(JSONObject json) throws JSONException {
    final URI baseUri = JsonParseUtil.parseURI(json.getString("baseUrl"));
    final String version = json.getString("version");
    final int buildNumber = json.getInt("buildNumber");
    final DateTime buildDate = JsonParseUtil.parseDateTime(json, "buildDate");
    final DateTime serverTime = JsonParseUtil.parseOptionalDateTime(json, "serverTime");
    final String scmInfo = json.getString("scmInfo");
    final String serverTitle = json.getString("serverTitle");
    return new ServerInfo(baseUri, version, buildNumber, buildDate, serverTime, scmInfo, serverTitle);
  }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

private void verifyAppAttemptsInfo(JSONObject info, RMAppAttempt appAttempt,
    String user)
    throws Exception {
 assertEquals("incorrect number of elements", 10, info.length());
 verifyAppAttemptInfoGeneric(appAttempt, info.getInt("id"),
     info.getLong("startTime"), info.getString("containerId"),
     info.getString("nodeHttpAddress"), info.getString("nodeId"),
     info.getString("logsLink"), user);
}

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-server-resourcemanager

public void verifyAppAttemptsInfo(JSONObject info, RMAppAttempt appAttempt,
  String user)
  throws JSONException, Exception {
 assertEquals("incorrect number of elements", 7, info.length());
 verifyAppAttemptInfoGeneric(appAttempt, info.getInt("id"),
   info.getLong("startTime"), info.getString("containerId"),
   info.getString("nodeHttpAddress"), info.getString("nodeId"),
   info.getString("logsLink"), user);
}

代码示例来源:origin: org.apache.hadoop/hadoop-mapreduce-client-app

public void verifyJobAttempts(JSONObject info, Job job)
  throws JSONException {
 JSONArray attempts = info.getJSONArray("jobAttempt");
 assertEquals("incorrect number of elements", 2, attempts.length());
 for (int i = 0; i < attempts.length(); i++) {
  JSONObject attempt = attempts.getJSONObject(i);
  verifyJobAttemptsGeneric(job, attempt.getString("nodeHttpAddress"),
    attempt.getString("nodeId"), attempt.getInt("id"),
    attempt.getLong("startTime"), attempt.getString("containerId"),
    attempt.getString("logsLink"));
 }
}

相关文章