org.codehaus.jackson.JsonNode.findValue()方法的使用及代码示例

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

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

JsonNode.findValue介绍

[英]Method for finding a JSON Object field with specified name in this node or its child nodes, and returning value it has. If no matching field is found in this node or its descendants, returns null.
[中]方法,用于在此节点或其子节点中查找具有指定名称的JSON对象字段,并返回其具有的值。如果在此节点或其子节点中未找到匹配字段,则返回null。

代码示例

代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl

@Override
public JsonNode findValue(String fieldName)
{
  if (_children != null) {
    for (JsonNode node : _children) {
      JsonNode value = node.findValue(fieldName);
      if (value != null) {
        return value;
      }
    }
  }
  return null;
}

代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl

@Override
public JsonNode findValue(String fieldName)
{
  if (_children != null) {
    for (Map.Entry<String, JsonNode> entry : _children.entrySet()) {
      if (fieldName.equals(entry.getKey())) {
        return entry.getValue();
      }
      JsonNode value = entry.getValue().findValue(fieldName);
      if (value != null) {
        return value;
      }
    }
  }
  return null;
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Override
public JsonNode findValue(String fieldName)
{
  if (_children != null) {
    for (JsonNode node : _children) {
      JsonNode value = node.findValue(fieldName);
      if (value != null) {
        return value;
      }
    }
  }
  return null;
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Override
public JsonNode findValue(String fieldName)
{
  if (_children != null) {
    for (Map.Entry<String, JsonNode> entry : _children.entrySet()) {
      if (fieldName.equals(entry.getKey())) {
        return entry.getValue();
      }
      JsonNode value = entry.getValue().findValue(fieldName);
      if (value != null) {
        return value;
      }
    }
  }
  return null;
}

代码示例来源:origin: KylinOLAP/Kylin

public Pair<RMAppState, FinalApplicationStatus> get() throws IOException {
  String applicationId = mrJobId.replace("job", "application");
  String url = yarnUrl.replace("${job_id}", applicationId);
  JsonNode root = new ObjectMapper().readTree(getHttpResponse(url));
  RMAppState state = RMAppState.valueOf(root.findValue("state").getTextValue());
  FinalApplicationStatus finalStatus = FinalApplicationStatus.valueOf(root.findValue("finalStatus").getTextValue());
  return Pair.of(state, finalStatus);
}

代码示例来源:origin: org.codehaus.jackson/jackson-mapper-lgpl

@Override
public JsonNode findValue(String fieldName)
{
  if (_children != null) {
    for (JsonNode node : _children) {
      JsonNode value = node.findValue(fieldName);
      if (value != null) {
        return value;
      }
    }
  }
  return null;
}

代码示例来源:origin: ovea-deprecated/jetty-session-redis

@Override
public JsonNode findValue(String fieldName)
{
  if (_children != null) {
    for (JsonNode node : _children) {
      JsonNode value = node.findValue(fieldName);
      if (value != null) {
        return value;
      }
    }
  }
  return null;
}

代码示例来源:origin: com.barchart.wrap/barchart-wrap-jackson

@Override
public JsonNode findValue(String fieldName)
{
  if (_children != null) {
    for (JsonNode node : _children) {
      JsonNode value = node.findValue(fieldName);
      if (value != null) {
        return value;
      }
    }
  }
  return null;
}

代码示例来源:origin: com.barchart.wrap/barchart-wrap-jackson

@Override
public JsonNode findValue(String fieldName)
{
  if (_children != null) {
    for (Map.Entry<String, JsonNode> entry : _children.entrySet()) {
      if (fieldName.equals(entry.getKey())) {
        return entry.getValue();
      }
      JsonNode value = entry.getValue().findValue(fieldName);
      if (value != null) {
        return value;
      }
    }
  }
  return null;
}

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

public ReadOnlyJsonNode findValue(final String fieldName)
{
  return wrap(delegate.findValue(fieldName));
}

代码示例来源:origin: org.codehaus.jackson/jackson-mapper-lgpl

@Override
public JsonNode findValue(String fieldName)
{
  if (_children != null) {
    for (Map.Entry<String, JsonNode> entry : _children.entrySet()) {
      if (fieldName.equals(entry.getKey())) {
        return entry.getValue();
      }
      JsonNode value = entry.getValue().findValue(fieldName);
      if (value != null) {
        return value;
      }
    }
  }
  return null;
}

代码示例来源:origin: ovea-deprecated/jetty-session-redis

@Override
public JsonNode findValue(String fieldName)
{
  if (_children != null) {
    for (Map.Entry<String, JsonNode> entry : _children.entrySet()) {
      if (fieldName.equals(entry.getKey())) {
        return entry.getValue();
      }
      JsonNode value = entry.getValue().findValue(fieldName);
      if (value != null) {
        return value;
      }
    }
  }
  return null;
}

代码示例来源:origin: org.rhq/rhq-jboss-as-7-plugin

/**
 * Inspects the supplied {@link JsonNode} instance and returns the json 'failure-description' node value as text.
 * 
 * @param jsonNode
 * @return
 */
public static String getFailureDescription(JsonNode jsonNode) {
  if (jsonNode == null) {
    return JSON_NODE_FAILURE_DESCRIPTION_VALUE_DEFAULT;
  }
  JsonNode node = jsonNode.findValue(JSON_NODE_FAILURE_DESCRIPTION);
  if (node == null) {
    return JSON_NODE_FAILURE_DESCRIPTION_VALUE_DEFAULT;
  }
  return node.getValueAsText();
}

代码示例来源:origin: Stratio/ingestion

private String getFieldName(Map<String, String> eventHeaders, String fieldName) {
  String value = null;
  if (fieldName.contains(".")) {
    ObjectMapper mapper = new ObjectMapper();
    final String[] fieldNameSplitted = fieldName.split("\\.");
    try {
      final String objectName = fieldNameSplitted[0];
      JsonNode jsonNode = mapper.readTree(eventHeaders.get(objectName));
      value = jsonNode.findValue(fieldNameSplitted[fieldNameSplitted.length - 1]).getTextValue();
    } catch (Exception e) {
      e.printStackTrace();
    }
  } else {
    value = eventHeaders.get(fieldName);
  }
  return value;
}

代码示例来源:origin: Orange-OpenSource/spring-social-weibo

@Override
  public boolean unfollow(long trendId) {
    requireAuthorization();
    MultiValueMap<String, String> request = new LinkedMultiValueMap<String, String>(
        1);
    request.add("trend_id", String.valueOf(trendId));
    return restTemplate
        .postForObject(buildUri("trends/destroy.json"), request,
            JsonNode.class).findValue("result").asBoolean();
  }
}

代码示例来源:origin: org.apache.kylin/kylin-job

public Pair<RMAppState, FinalApplicationStatus> get(boolean useKerberos) throws IOException {
  String applicationId = mrJobId.replace("job", "application");
  String url = yarnUrl.replace("${job_id}", applicationId);
  String response = useKerberos ? getHttpResponseWithKerberosAuth(url) : getHttpResponse(url);
  JsonNode root = new ObjectMapper().readTree(response);
  RMAppState state = RMAppState.valueOf(root.findValue("state").getTextValue());
  FinalApplicationStatus finalStatus = FinalApplicationStatus.valueOf(root.findValue("finalStatus").getTextValue());
  return Pair.of(state, finalStatus);
}

代码示例来源:origin: org.rhq/rhq-jboss-as-7-plugin

/**
 * Inspects the supplied {@link JsonNode} instance to determine if it represents an error outcome.
 * 
 * @param jsonNode
 * @return
 */
public static boolean isErrorReply(JsonNode jsonNode) {
  if (jsonNode == null) {
    return true;
  }
  if (jsonNode.has(JSON_NODE_OUTCOME)) {
    String outcome = null;
    try {
      JsonNode outcomeNode = jsonNode.findValue(JSON_NODE_OUTCOME);
      outcome = outcomeNode.getTextValue();
      if (outcome.equals(JSON_NODE_OUTCOME_VALUE_FAILED)) {
        return true;
      }
    } catch (Exception e) {
      LOG.error(e);
      return true;
    }
  }
  return false;
}

代码示例来源:origin: sequenceiq/sequenceiq-samples

JsonNode queueNode = queues.get(i);                        
LOGGER.info("queueName / usedCapacity / absoluteUsedCap / absoluteCapacity / absMaxCapacity: " + 
    queueNode.findValue("queueName") + " / " +
    queueNode.findValue("usedCapacity") + " / " + 
    queueNode.findValue("absoluteUsedCapacity") + " / " + 
    queueNode.findValue("absoluteCapacity") + " / " +
    queueNode.findValue("absoluteMaxCapacity"));

代码示例来源:origin: Orange-OpenSource/spring-social-weibo

@Override
public long follow(String trendName) {
  requireAuthorization();
  MultiValueMap<String, String> request = new LinkedMultiValueMap<String, String>(
      1);
  request.add("trend_name", trendName);
  return restTemplate
      .postForObject(buildUri("trends/follow.json"), request,
          JsonNode.class).findValue("topicid").asLong();
}

代码示例来源:origin: org.springframework.data/spring-data-commons-core

/**
   * Reads the given {@link JsonNode} into an instance of the type encoded in it using the configured type key.
   * 
   * @param node must not be {@literal null}.
   * @param classLoader
   * @return
   */
  private Object readSingle(JsonNode node, ClassLoader classLoader) throws IOException {

    JsonNode typeNode = node.findValue(typeKey);
    String typeName = typeNode == null ? null : typeNode.asText();

    Class<?> type = ClassUtils.resolveClassName(typeName, classLoader);

    return mapper.reader(type).readValue(node);
  }
}

相关文章