com.fasterxml.jackson.databind.JsonNode.booleanValue()方法的使用及代码示例

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

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

JsonNode.booleanValue介绍

[英]Method to use for accessing JSON boolean values (value literals 'true' and 'false'). For other types, always returns false.
[中]用于访问JSON布尔值(值文本“true”和“false”)的方法。对于其他类型,始终返回false。

代码示例

代码示例来源:origin: java-json-tools/json-schema-validator

public MaximumValidator(final JsonNode digest)
{
  super("maximum", digest);
  exclusive = digest.path("exclusive").booleanValue();
}

代码示例来源:origin: java-json-tools/json-schema-validator

public UniqueItemsValidator(final JsonNode digest)
{
  super("uniqueItems");
  uniqueItems = digest.get(keyword).booleanValue();
}

代码示例来源:origin: java-json-tools/json-schema-validator

protected NumericValidator(final String keyword, final JsonNode digest)
{
  super(keyword);
  number = digest.get(keyword);
  isLong = digest.get("valueIsLong").booleanValue();
}

代码示例来源:origin: java-json-tools/json-schema-validator

public ArraySchemaSelector(final JsonNode digest)
{
  hasItems = digest.get("hasItems").booleanValue();
  itemsIsArray = digest.get("itemsIsArray").booleanValue();
  itemsSize = digest.get("itemsSize").intValue();
  hasAdditional = digest.get("hasAdditional").booleanValue();
}

代码示例来源:origin: aws/aws-sdk-java

@Override
BinaryConditionBuilder expectedValue(JsonNode expectedValue) {
  return expectedValue(expectedValue.booleanValue());
}

代码示例来源:origin: java-json-tools/json-schema-validator

public ObjectSchemaSelector(final JsonNode digest)
{
  hasAdditional = digest.get("hasAdditional").booleanValue();
  List<String> list;
  list = Lists.newArrayList();
  for (final JsonNode node: digest.get("properties"))
    list.add(node.textValue());
  properties = ImmutableList.copyOf(list);
  list = Lists.newArrayList();
  for (final JsonNode node: digest.get("patternProperties"))
    list.add(node.textValue());
  patternProperties = ImmutableList.copyOf(list);
}

代码示例来源:origin: java-json-tools/json-schema-validator

public AdditionalPropertiesValidator(final JsonNode digest)
{
  super("additionalProperties");
  additionalOK = digest.get(keyword).booleanValue();
  ImmutableSet.Builder<String> builder;
  builder = ImmutableSet.builder();
  for (final JsonNode node: digest.get("properties"))
    builder.add(node.textValue());
  properties = builder.build();
  builder = ImmutableSet.builder();
  for (final JsonNode node: digest.get("patternProperties"))
    builder.add(node.textValue());
  patternProperties = builder.build();
}

代码示例来源:origin: java-json-tools/json-schema-validator

public AdditionalItemsValidator(final JsonNode digest)
{
  super("additionalItems");
  additionalOK = digest.get(keyword).booleanValue();
  itemsSize = digest.get("itemsSize").intValue();
}

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

@Override
public Void handleResponse(HttpRequest<?> httpRequest, InputStream is, Integer statusCode, IOException e) throws IOException {
  if (is == null) {
    return null;
  }
  final JsonNode bulkResponse = JsonUtils.getMapper().readTree(is);
  final JsonNode errors = bulkResponse.get("errors");
  if (errors != null && errors.booleanValue()) {
    reportBulkErrors(bulkResponse.get("items"));
  }
  return null;
}

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

@Override
public Void handleResponse(HttpRequest<?> httpRequest, InputStream is, Integer statusCode, IOException e) throws IOException {
  if (is == null) {
    // don't log exception as it might contain basic auth credentials (see #362)
    logger.warn("Error while sending bulk request to Elasticsearch. Status {}", statusCode);
    return null;
  }
  final JsonNode bulkResponse = JsonUtils.getMapper().readTree(is);
  final JsonNode errors = bulkResponse.get("errors");
  if (errors != null && errors.booleanValue()) {
    logger.warn(ERROR_PREFIX, reportBulkErrors(bulkResponse.get("items")));
  } else if (bulkResponse.get("error") != null) {
    logger.warn(ERROR_PREFIX, bulkResponse);
  }
  return null;
}

代码示例来源:origin: spring-io/initializr

/**
 * Return the boot versions parsed by this instance.
 * @return the versions
 */
public List<DefaultMetadataElement> getBootVersions() {
  ArrayNode releases = (ArrayNode) this.content.get("projectReleases");
  List<DefaultMetadataElement> list = new ArrayList<>();
  for (JsonNode node : releases) {
    DefaultMetadataElement version = new DefaultMetadataElement();
    version.setId(node.get("version").textValue());
    String name = node.get("versionDisplayName").textValue();
    version.setName(
        node.get("snapshot").booleanValue() ? name + " (SNAPSHOT)" : name);
    version.setDefault(node.get("current").booleanValue());
    list.add(version);
  }
  return list;
}

代码示例来源:origin: Graylog2/graylog2-server

return read.booleanValue();
case MISSING:
case NULL:

代码示例来源:origin: java-json-tools/json-schema-validator

@DataProvider
public final Iterator<Object[]> getAllTests()
{
  final List<Object[]> list = Lists.newArrayList();
  for (final JsonNode test: testSuite)
    list.add(new Object[]{
      test.get("description").textValue(),
      test.get("schema"),
      test.get("data"),
      test.get("valid").booleanValue()
    });
  return list.iterator();
}

代码示例来源:origin: java-json-tools/json-schema-validator

@DataProvider
protected final Iterator<Object[]> getValueTests()
{
  final List<Object[]> list = Lists.newArrayList();
  String msg;
  JsonNode msgNode, msgData, msgParams;
  for (final JsonNode node: testNode) {
    msgNode = node.get("message");
    msgData = node.get("msgData");
    msgParams = node.get("msgParams");
    msg = msgNode == null ? null
      : buildMessage(msgNode.textValue(), msgParams, msgData);
    list.add(new Object[]{ node.get("digest"), node.get("data"), msg,
      node.get("valid").booleanValue(), msgData });
  }
  return list.iterator();
}

代码示例来源:origin: java-json-tools/json-schema-validator

@DataProvider
public final Iterator<Object[]> testData()
{
  final List<Object[]> list = Lists.newArrayList();
  String msg;
  JsonNode msgNode, msgData, msgParams;
  for (final JsonNode node: testNode) {
    msgNode = node.get("message");
    msgData = node.get("msgData");
    msgParams = node.get("msgParams");
    msg = msgNode == null ? null
      : buildMessage(msgNode.textValue(), msgParams, msgData);
    list.add(new Object[]{ node.get("data"),
      node.get("valid").booleanValue(), msg, msgData });
  }
  return list.iterator();
}

代码示例来源:origin: java-json-tools/json-schema-validator

@DataProvider
public Iterator<Object[]> getValueTests()
{
  final List<Object[]> list = Lists.newArrayList();
  String msg;
  JsonNode msgNode, msgData, msgParams;
  for (final JsonNode node: testData) {
    msgNode = node.get("message");
    msgData = node.get("msgData");
    msgParams = node.get("msgParams");
    msg = msgNode == null ? null
      : TestUtils.buildMessage(BUNDLE, msgNode.textValue(),
        msgParams, msgData);
    list.add(new Object[]{ node.get("schema"), node.get("data"), msg,
      node.get("valid").booleanValue(), node.get("msgData") });
  }
  return list.iterator();
}

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

private void validateSpanJson(JsonNode spanJson) {
  assertThat(spanJson.get("error").booleanValue()).as(spanJson.toString()).isFalse();
  assertThat(spanJson.get("foo.bar").asText()).as(spanJson.toString()).isEqualTo("baz");
  assertThat(spanJson.get("parameters")).as(spanJson.toString()).isNotNull();
  assertThat(spanJson.get("parameters").size()).as(spanJson.toString()).isEqualTo(3);
  assertThat(spanJson.get("parameters").get(0).get("key")).as(spanJson.toString()).isNotNull();
  assertThat(spanJson.get("parameters").get(0).get("value")).as(spanJson.toString()).isNotNull();
}

代码示例来源:origin: Graylog2/graylog2-server

return ValueReference.of(value.booleanValue());
} else if (valueType == ValueType.DOUBLE && value.isDouble()) {
  return ValueReference.of(value.doubleValue());

代码示例来源:origin: spring-io/initializr

@Test
void mapTemplatedRel() {
  List<Link> links = new ArrayList<>();
  links.add(Link.create("a", "https://example.com/{bootVersion}/a", true));
  ObjectNode model = LinkMapper.mapLinks(links);
  assertThat(model).hasSize(1);
  assertThat(model.has("a")).isTrue();
  ObjectNode linkModel = (ObjectNode) model.get("a");
  assertThat(linkModel).hasSize(2);
  assertThat(linkModel.get("href").textValue())
      .isEqualTo("https://example.com/{bootVersion}/a");
  assertThat(linkModel.get("templated").booleanValue()).isEqualTo(true);
}

代码示例来源:origin: java-json-tools/json-schema-validator

private static Object valueToArgument(final JsonNode value)
  {
    final NodeType type = NodeType.getNodeType(value);

    switch (type) {
      case STRING:
        return value.textValue();
      case INTEGER:
        return value.bigIntegerValue();
      case NUMBER: case NULL: case OBJECT: case ARRAY:
        return value;
      case BOOLEAN:
        return value.booleanValue();
//            case ARRAY:
//                final List<Object> list = Lists.newArrayList();
//                for (final JsonNode element: value)
//                    list.add(valueToArgument(element));
//                return list;
      default:
        throw new UnsupportedOperationException();
    }
  }
}

相关文章