net.sf.json.JSONObject.optJSONObject()方法的使用及代码示例

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

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

JSONObject.optJSONObject介绍

暂无

代码示例

代码示例来源:origin: jenkinsci/jenkins

public Node reconfigure(final StaplerRequest req, JSONObject form) throws FormException {
  if (form==null)     return null;
  final JSONObject jsonForProperties = form.optJSONObject("nodeProperties");
  final AtomicReference<BindInterceptor> old = new AtomicReference<>();
  old.set(req.setBindListener(new BindInterceptor() {
    @Override
    public Object onConvert(Type targetType, Class targetTypeErasure, Object jsonSource) {
      if (jsonForProperties != jsonSource) {
        return old.get().onConvert(targetType, targetTypeErasure, jsonSource);
      }
      try {
        DescribableList<NodeProperty<?>, NodePropertyDescriptor> tmp = new DescribableList<NodeProperty<?>, NodePropertyDescriptor>(Saveable.NOOP,getNodeProperties().toList());
        tmp.rebuild(req, jsonForProperties, NodeProperty.all());
        return tmp.toList();
      } catch (FormException e) {
        throw new IllegalArgumentException(e);
      } catch (IOException e) {
        throw new IllegalArgumentException(e);
      }
    }
  }));
  try {
    return getDescriptor().newInstance(req, form);
  } finally {
    req.setBindListener(old.get());
  }
}

代码示例来源:origin: jenkinsci/jenkins

Data(JSONObject o) {
  this.sourceId = Util.intern((String)o.get("id"));
  JSONObject c = o.optJSONObject("core");
  if (c!=null) {
    core = new Entry(sourceId, c, url);

代码示例来源:origin: jenkinsci/jenkins

T existing = get((D)d);
String name = d.getJsonSafeClassName();
JSONObject o = json.optJSONObject(name);

代码示例来源:origin: jenkinsci/jenkins

@Override
  public boolean configure(StaplerRequest req, JSONObject json) throws hudson.model.Descriptor.FormException {
    // for compatibility reasons, the actual value is stored in Jenkins
    Jenkins j = Jenkins.get();
    final JSONObject optJSONObject = json.optJSONObject("useProjectNamingStrategy");
    if (optJSONObject != null) {
      final JSONObject strategyObject = optJSONObject.getJSONObject("namingStrategy");
      final String className = strategyObject.getString("$class");
      try {
        Class clazz = Class.forName(className, true, j.getPluginManager().uberClassLoader);
        final ProjectNamingStrategy strategy = (ProjectNamingStrategy) req.bindJSON(clazz, strategyObject);
        j.setProjectNamingStrategy(strategy);
      } catch (ClassNotFoundException e) {
        throw new FormException(e, "namingStrategy");
      }
    }
    if (j.getProjectNamingStrategy() == null) {
      j.setProjectNamingStrategy(DefaultProjectNamingStrategy.DEFAULT_NAMING_STRATEGY);
    }
    return true;
  }
}

代码示例来源:origin: jenkinsci/jenkins

UserProperty p = getProperty(d.clazz);
JSONObject o = json.optJSONObject("userProperty" + (i++));
if (o != null) {
  if (p != null) {

代码示例来源:origin: jenkinsci/jenkins

/**
 * Accepts submission from the node configuration page.
 */
@RequirePOST
public synchronized void doConfigExecutorsSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, FormException {
  checkPermission(ADMINISTER);
  BulkChange bc = new BulkChange(this);
  try {
    JSONObject json = req.getSubmittedForm();
    ExtensionList.lookupSingleton(MasterBuildConfiguration.class).configure(req,json);
    getNodeProperties().rebuild(req, json.optJSONObject("nodeProperties"), NodeProperty.all());
  } finally {
    bc.commit();
  }
  updateComputerList();
  rsp.sendRedirect(req.getContextPath()+'/'+toComputer().getUrl());  // back to the computer page
}

代码示例来源:origin: jenkinsci/jenkins

JSONObject jsonProperties = json.optJSONObject("properties");
if (jsonProperties != null) {
 t.rebuild(req,jsonProperties,JobPropertyDescriptor.getPropertyDescriptors(Job.this.getClass()));

代码示例来源:origin: com.cloudbees.mtslaves/mansion-client

/**
 * The failed configurator may pass in additional information about the failure.
 */
public JSONObject getDetails() {
  return json.optJSONObject("cause");
}

代码示例来源:origin: com.cloudbees.mtslaves/mansion-client

/**
 * The failed configurator may pass in additional information about the failure.
 */
public JSONObject getDetails() {
  return json.optJSONObject("cause");
}

代码示例来源:origin: com.cloudbees.mtslaves/mansion-client

public JSONObject getProperty(String name) {
  return properties.optJSONObject(name);
}

代码示例来源:origin: gooddata/GoodData-CL

public JSONObject optJSONObject(String key) {
  return jsonObject.optJSONObject(key);
}

代码示例来源:origin: etsy/jenkins-master-project

@Override
 public JobProperty<?> newInstance(
   StaplerRequest req, JSONObject formData) 
   throws Descriptor.FormException {
  JSONObject property = formData.optJSONObject("subProjectsJobProperty");
  if (property == null) {
   return null;
  }
  String subProjects = property.getString("defaultSubProjects");
  String hiddenProjects = property.getString("hiddenSubProjects");
  return new SubProjectsJobProperty(subProjects, hiddenProjects);
 }
}

代码示例来源:origin: etsy/jenkins-master-project

@Override
 public JobProperty<?> newInstance(
   StaplerRequest req,
   JSONObject formData)
   throws Descriptor.FormException {
  JSONObject property = formData.optJSONObject("rebuildRedsJobProperty");
  if (property == null) {
   return null;
  }
  int maxRetries = Integer.parseInt(property.getString("maxRetries"));
  return new RebuildRedsJobProperty(maxRetries);
 }
}

代码示例来源:origin: mbreese/couchdb4j

public JSONObject optJSONObject(String arg0) {
  return getJSONObject().optJSONObject(arg0);
}
public long optLong(String arg0, long arg1) {

代码示例来源:origin: jenkinsci/dockerhub-notification-plugin

@CheckForNull
public String getTag() {
  JSONObject data = getWebHookPayload().getData();
  if (data != null) {
    JSONObject push_data = data.optJSONObject("push_data");
    if (push_data != null) {
      return push_data.optString("tag");
    }
  }
  return null;
}

代码示例来源:origin: jenkinsci/dockerhub-notification-plugin

@CheckForNull
public String getPusher() {
  JSONObject data = getWebHookPayload().getData();
  if (data != null) {
    JSONObject push_data = data.optJSONObject("push_data");
    if (push_data != null) {
      return push_data.optString("pusher");
    }
  }
  return null;
}

代码示例来源:origin: itesla/ipst

private static boolean isTrueCondition(JSONObject stats, JSONObject node, double purityThreshold, int trueIdx) {
  String nodeIdx = node.optString("id");
  JSONArray nodeValues = stats.optJSONObject(nodeIdx).optJSONArray("counts");
  double purity = ((double) nodeValues.optInt(trueIdx)) / stats.optJSONObject(nodeIdx).optInt("count");
  return purity >= purityThreshold && node.optBoolean("value");
}

代码示例来源:origin: org.jenkins-ci.plugins/dependency-track

private Finding parseFinding(JSONObject json) {
  final Component component = parseComponent(json.getJSONObject("component"));
  final Vulnerability vulnerability = parseVulnerability(json.getJSONObject("vulnerability"));
  final Analysis analysis = parseAnalysis(json.optJSONObject("analysis"));
  final String matrix = StringUtils.trimToNull(json.getString("matrix"));
  return new Finding(component, vulnerability, analysis, matrix);
}

代码示例来源:origin: jenkinsci/promoted-builds-plugin

/*package*/ void configure(StaplerRequest req, JSONObject c) throws Descriptor.FormException, IOException {
  // apply configuration
  conditions.rebuild(req,c.optJSONObject("conditions"), PromotionCondition.all());
  buildSteps = (List)Descriptor.newInstancesFromHeteroList(
      req, c, "buildStep", (List) PromotionProcess.getAll());
  icon = c.getString("icon");
  if (c.optBoolean("hasAssignedLabel")) {
    assignedLabel = Util.fixEmptyAndTrim(c.optString("assignedLabelString"));
  } else {
    assignedLabel = null;
  }
  isVisible = c.getString("isVisible");
  save();
}

代码示例来源:origin: jenkinsci/selenium-plugin

@Override
public void configure(StaplerRequest req, JSONObject formData)
    throws IOException, ServletException, Descriptor.FormException {
  super.configure(req, formData);
  port = formData.optInt("port", 4444);
  exclusionPatterns = formData.getString("exclusionPatterns");
  hubLogLevel = formData.getString("hubLogLevel");
  newSessionWaitTimeout = formData.optInt("newSessionWaitTimeout", -1);
  maxSession = formData.optInt("maxSession", 5);
  timeout = formData.optInt("timeout", 300000);
  browserTimeout = formData.optInt("browserTimeout", 0);
  throwOnCapabilityNotPresent = formData.getBoolean("throwOnCapabilityNotPresent");
  hostnameResolver = req.bindJSON(HostnameResolver.class, formData.optJSONObject("hostnameResolver"));
  if (hostnameResolver == null)
    hostnameResolver = new JenkinsRootHostnameResolver();
  save();
}

相关文章

微信公众号

最新文章

更多