com.atlassian.jira.util.json.JSONObject.optInt()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(1.4k)|赞(0)|评价(0)|浏览(118)

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

JSONObject.optInt介绍

[英]Get an optional int value associated with a key, or zero if there is no such key or if the value is not a number. If the value is a string, an attempt will be made to evaluate it as a number.
[中]获取与键关联的可选int值,如果没有此类键或该值不是数字,则获取零。如果该值是字符串,将尝试将其作为数字计算。

代码示例

代码示例来源:origin: com.atlassian.jira/jira-api

/**
 * Get an optional int value associated with a key,
 * or zero if there is no such key or if the value is not a number.
 * If the value is a string, an attempt will be made to evaluate it as
 * a number.
 *
 * @param key A key string.
 * @return An object which is the value.
 */
public int optInt(final String key)
{
  return optInt(key, 0);
}

代码示例来源:origin: com.atlassian.jira.plugins/jira-dvcs-connector-api

JSONObject jsoned = new JSONObject(message.getPayload());
int version = jsoned.optInt("version", 0);
P result = deserializeInternal(jsoned, version);
deserialized.repository = repositoryService.get(jsoned.optInt("repository"));

代码示例来源:origin: com.marvelution.jira.plugins/jira-jenkins-plugin

final JSONObject firstBuild = json.optJSONObject("firstBuild");
if (firstBuild != null && firstBuild.has("number")) {
  job.setOldestBuild(firstBuild.optInt("number", -1));

相关文章