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

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

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

JSONObject.has介绍

[英]Determine if the JSONObject contains a specific key.
[中]确定JSONObject是否包含特定的键。

代码示例

代码示例来源:origin: eBay/parallec

final List<String> labelList = new ArrayList<String>();
if (!jObj.has("result")) {
  logger.error("!!CMS_ERROR! result key is not in jOBJ in getFQDNValueListCMS!!: \njObj:"
      + PcStringUtils.renderJson(jObj));
  if (!agentObj.has(projectionStr)) {
    continue;

代码示例来源:origin: eBay/parallec

hasMoreNextUrl = null;
if (jsonObjectNext.has(KEY_HAS_MORE)) {
  hasMore = jsonObjectNext.getBoolean(KEY_HAS_MORE);
  if (jsonObjectNext.has(KEY_NEXT_PARENT)
      && jsonObjectNext.getJSONObject(KEY_NEXT_PARENT)
          .has(KEY_NEXT_URL)) {
    hasMoreNextUrl = jsonObjectNext.getJSONObject(
        KEY_NEXT_PARENT).getString(KEY_NEXT_URL);

代码示例来源:origin: opensourceBIM/BIMserver

sServiceDescriptor.setReadRevision(rights.has("readRevision") && rights.getBoolean("readRevision"));
sServiceDescriptor.setReadExtendedData(rights.has("readExtendedData") ? rights.getString("readExtendedData") : null);
sServiceDescriptor.setWriteRevision(rights.has("writeRevision") && rights.getBoolean("writeRevision"));
sServiceDescriptor.setWriteExtendedData(rights.has("writeExtendedData") ? rights.getString("writeExtendedData") : null);
sServiceDescriptors.add(sServiceDescriptor);

代码示例来源: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: org.openengsb.wrapped/jira-rest-java-client-core

static Iterable<String> parseExpandos(final JSONObject json) throws JSONException
{
  if (json.has("expand")) {
    final String expando = json.getString("expand");
    return Splitter.on(',').split(expando);
  } else {
    return Collections.emptyList();
  }
}

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

@Nullable
public static String tryGetString(JSONObject jsonObject, String key) throws JSONException {
 if (jsonObject.has(key)) {
  return jsonObject.getString(key);
 }
 return null;
}

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

public static Optional<JSONArray> getOptionalArray(final JSONObject jsonObject, final String attributeName)
    throws JSONException {
  return jsonObject.has(attributeName) ?
      Optional.of(jsonObject.getJSONArray(attributeName)) : Optional.<JSONArray>absent();
}

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

public static Optional<JSONArray> getOptionalArray(final JSONObject jsonObject, final String attributeName)
    throws JSONException {
  return jsonObject.has(attributeName) ?
      Optional.of(jsonObject.getJSONArray(attributeName)) : Optional.<JSONArray>absent();
}

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

private ContainerLogFileInfo generatePerContainerLogFileInfoFromJSON(
  JSONObject meta) throws JSONException {
 String fileName = meta.has("fileName") ?
   meta.getString("fileName") : "N/A";
 String fileSize = meta.has("fileSize") ?
   meta.getString("fileSize") : "N/A";
 String lastModificationTime = meta.has("lastModifiedTime") ?
   meta.getString("lastModifiedTime") : "N/A";
 return new ContainerLogFileInfo(fileName, fileSize,
   lastModificationTime);
}

代码示例来源:origin: GluuFederation/oxAuth

public void injectErrorIfExistSilently(JSONObject jsonObj) throws JSONException {
  if (jsonObj.has("error")) {
    errorType = fromString(jsonObj.getString("error"));
  }
  if (jsonObj.has("error_description")) {
    errorDescription = jsonObj.getString("error_description");
  }
  if (jsonObj.has("error_uri")) {
    errorUri = jsonObj.getString("error_uri");
  }
}

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

public Address(JSONObject jObj) throws JSONException {
 _publicIp = Ip.parse(jObj.getString(JSON_KEY_PUBLIC_IP));
 _instanceId = jObj.has(JSON_KEY_INSTANCE_ID) ? jObj.getString(JSON_KEY_INSTANCE_ID) : null;
 _privateIp =
   jObj.has(JSON_KEY_PRIVATE_IP_ADDRESS)
     ? Ip.parse(jObj.getString(JSON_KEY_PRIVATE_IP_ADDRESS))
     : null;
 // TODO: not sure what other information we need to pull
}

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

private JSONObject getFieldUnisex(JSONObject json, String attributeName) throws JSONException {
  final JSONObject fieldsJson = json.getJSONObject(FIELDS);
  final JSONObject fieldJson = fieldsJson.getJSONObject(attributeName);
  if (fieldJson.has(VALUE_ATTR)) {
    return fieldJson.getJSONObject(VALUE_ATTR); // pre 5.0 way
  } else {
    return fieldJson; // JIRA 5.0 way
  }
}

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

private JSONObject getFieldUnisex(JSONObject json, String attributeName) throws JSONException {
  final JSONObject fieldsJson = json.getJSONObject(FIELDS);
  final JSONObject fieldJson = fieldsJson.getJSONObject(attributeName);
  if (fieldJson.has(VALUE_ATTR)) {
    return fieldJson.getJSONObject(VALUE_ATTR); // pre 5.0 way
  } else {
    return fieldJson; // JIRA 5.0 way
  }
}

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

@VisibleForTesting
public String getNodeHttpAddressFromRMWebString(ContainerLogsRequest request)
  throws ClientHandlerException, UniformInterfaceException, JSONException {
 if (request.getNodeId() == null || request.getNodeId().isEmpty()) {
  return null;
 }
 JSONObject nodeInfo = YarnWebServiceUtils
   .getNodeInfoFromRMWebService(getConf(), request.getNodeId())
   .getJSONObject("node");
 return nodeInfo.has("nodeHTTPAddress") ?
   nodeInfo.getString("nodeHTTPAddress") : null;
}

代码示例来源:origin: ModeShape/modeshape

private Property updateProperty( Property property,
                 JSONObject jsonItem ) throws RepositoryException, JSONException {
  String propertyName = property.getName();
  String jsonPropertyName = jsonItem.has(propertyName) ? propertyName : propertyName + BASE64_ENCODING_SUFFIX;
  Node node = property.getParent();
  setPropertyOnNode(node, jsonPropertyName, jsonItem.get(jsonPropertyName));
  return property;
}

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

@Override
  public ChangelogGroup parse(JSONObject json) throws JSONException {
    final DateTime created = JsonParseUtil.parseDateTime(json, "created");
    final BasicUser author = json.has("author") ? JsonParseUtil.parseBasicUser(json.getJSONObject("author")) : null;
    final Collection<ChangelogItem> items = JsonParseUtil.parseJsonArray(json.getJSONArray("items"), changelogItemJsonParser);
    return new ChangelogGroup(author, created, items);
  }
}

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

public static DelegationToken getDelegationTokenFromJson(JSONObject json)
  throws JSONException {
 DelegationToken ret = new DelegationToken();
 if (json.has("token")) {
  ret.setToken(json.getString("token"));
 } else if (json.has("expiration-time")) {
  ret.setNextExpirationTime(json.getLong("expiration-time"));
 }
 return ret;
}

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

private void verifyResourcesContainDefaultResourceTypes(JSONObject queue,
  Set<String> resourceCategories) throws JSONException {
 for (String resourceCategory : resourceCategories) {
  boolean hasResourceCategory = queue.has(resourceCategory);
  assertTrue("Queue " + queue + " does not have resource category key: "
    + resourceCategory, hasResourceCategory);
  verifyResourceContainsDefaultResourceTypes(
    queue.getJSONObject(resourceCategory));
 }
}

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

private void verifyResourcesContainCustomResourceTypes(JSONObject queue,
  Set<String> resourceCategories) throws JSONException {
 for (String resourceCategory : resourceCategories) {
  assertTrue("Queue " + queue + " does not have resource category key: "
    + resourceCategory, queue.has(resourceCategory));
  verifyResourceContainsAllCustomResourceTypes(
    queue.getJSONObject(resourceCategory));
 }
}

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

@Override
public Field parse(final JSONObject jsonObject) throws JSONException {
  final String id = jsonObject.getString("id");
  final String name = jsonObject.getString("name");
  final Boolean orderable = jsonObject.getBoolean("orderable");
  final Boolean navigable = jsonObject.getBoolean("navigable");
  final Boolean searchable = jsonObject.getBoolean("searchable");
  final FieldType custom = jsonObject.getBoolean("custom") ? FieldType.CUSTOM : FieldType.JIRA;
  final FieldSchema schema = jsonObject.has("schema") ? schemaJsonParser.parse(jsonObject.getJSONObject("schema")) : null;
  return new Field(id, name, custom, orderable, navigable, searchable, schema);
}

相关文章