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

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

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

JSONObject.optJSONObject介绍

[英]Get an optional JSONObject associated with a key. It returns null if there is no such key, or if its value is not a JSONObject.
[中]获取与键关联的可选JSONObject。如果没有这样的键,或者其值不是JSONObject,则返回null。

代码示例

代码示例来源:origin: com.atlassian.plugin.deflection/deflection-cse

private String getEmbedURL(JSONObject result) throws JSONException
{
  final JSONObject richSnippet = result.optJSONObject("richSnippet");
  if (richSnippet != null)
  {
    final JSONObject metatags = richSnippet.optJSONObject("metatags");
    if (metatags != null)
    {
      final String pageId = metatags.optString("ajsPageId", null);
      if (StringUtils.isNumeric(pageId))
      {
        final String[] hostnames = StringUtils.substringsBetween(result.getString("unescapedUrl"), "//", "/");
        if (hostnames.length == 1)
        {
          return String.format("https://%s/plugins/servlet/remotepageview?pageId=%s", hostnames[0], pageId);
        }
      }
    }
  }
  return "";
}

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

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

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

final JSONObject changeSet = jsonBuild.optJSONObject("changeSet");
if (changeSet != null && changeSet.has("items")) {
  final JSONArray items = changeSet.optJSONArray("items");

相关文章