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

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

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

JsonNode.textValue介绍

[英]Method to use for accessing String values. Does NOT do any conversions for non-String value nodes; for non-String values (ones for which #isTextual returns false) null will be returned. For String values, null is never returned (but empty Strings may be)
[中]用于访问字符串值的方法。不为非字符串值节点进行任何转换;对于非字符串值(即#isTextual返回false的值),将返回null。对于字符串值,永远不会返回null(但可能会返回空字符串)

代码示例

代码示例来源:origin: joelittlejohn/jsonschema2pojo

/**
 * Get name of the field generated from property.
 *
 * @param propertyName
 * @param node
 * @return
 */
public String getFieldName(String propertyName, JsonNode node) {
  if (node != null && node.has("javaName")) {
    propertyName = node.get("javaName").textValue();
  }
  return propertyName;
}

代码示例来源:origin: apache/avro

private String parseDocNode(JsonNode json) {
 JsonNode nameNode = json.get("doc");
 if (nameNode == null) return null;                 // no doc defined
 return nameNode.textValue();
}

代码示例来源:origin: apache/avro

/** Extracts text value associated to key from the container JsonNode. */
private static String getOptionalText(JsonNode container, String key) {
 JsonNode jsonNode = container.get(key);
 return jsonNode != null ? jsonNode.textValue() : null;
}

代码示例来源:origin: apache/incubator-pinot

@Override
public String getString(int rowIndex, int columnIndex) {
 JsonNode jsonValue = _resultsArray.get(rowIndex).get(columnIndex);
 if (jsonValue.isTextual()) {
  return jsonValue.textValue();
 } else {
  return jsonValue.toString();
 }
}

代码示例来源:origin: joelittlejohn/jsonschema2pojo

public String getClassName(String propertyName, JsonNode node) {
  if (node != null) {
    if (node.has("javaName")) {
      propertyName = node.get("javaName").textValue();
    } else if (generationConfig.isUseTitleAsClassname() && node.has("title")) {
      String title = node.get("title").textValue();
      propertyName = WordUtils.capitalize(title).replaceAll(" ", "");
    }
  }
  return propertyName;
}

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

public PropertiesValidator(final JsonNode digest)
{
  super("properties");
  final ImmutableSet.Builder<String> builder = ImmutableSet.builder();
  for (final JsonNode element: digest.get("required"))
    builder.add(element.textValue());
  required = builder.build();
}

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

public RequiredKeywordValidator(final JsonNode digest)
{
  super("required");
  final ImmutableSet.Builder<String> builder = ImmutableSet.builder();
  for (final JsonNode element: digest.get(keyword))
    builder.add(element.textValue());
  required = builder.build();
}

代码示例来源: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 DraftV4TypeValidator(final JsonNode digest)
{
  super("type");
  for (final JsonNode node: digest.get(keyword))
    types.add(NodeType.fromName(node.textValue()));
}

代码示例来源:origin: apache/avro

private void parseName(JsonNode json) {
 JsonNode nameNode = json.get("protocol");
 if (nameNode == null)
  throw new SchemaParseException("No protocol name specified: "+json);
 this.name = nameNode.textValue();
}

代码示例来源:origin: apache/avro

private void parseNamespace(JsonNode json) {
 JsonNode nameNode = json.get("namespace");
 if (nameNode == null) return;                 // no namespace defined
 this.namespace = nameNode.textValue();
 types.space(this.namespace);
}

代码示例来源:origin: knowm/XChange

@Override
 public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
   throws IOException {

  ObjectCodec oc = jsonParser.getCodec();
  JsonNode node = oc.readTree(jsonParser);
  if (node.isTextual()) {
   return node.textValue();
  } else if (node.isObject()) {
   JsonNode allNode = node.get("__all__");
   if (allNode != null && allNode.isArray()) {
    StringBuilder buf = new StringBuilder();
    for (JsonNode msgNode : allNode) {
     buf.append(msgNode.textValue());
     buf.append(",");
    }

    return buf.length() > 0 ? buf.substring(0, buf.length() - 1) : buf.toString();
   }

   return node.toString();
  }

  return null;
 }
}

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

protected DraftV3TypeKeywordValidator(final String keyword,
  final JsonNode digested)
{
  super(keyword);
  for (final JsonNode element: digested.get(keyword))
    types.add(NodeType.fromName(element.textValue()));
  for (final JsonNode element: digested.get("schemas"))
    schemas.add(element.intValue());
}

代码示例来源:origin: apache/avro

static Set<String> parseAliases(JsonNode node) {
 JsonNode aliasesNode = node.get("aliases");
 if (aliasesNode == null)
  return null;
 if (!aliasesNode.isArray())
  throw new SchemaParseException("aliases not an array: "+node);
 Set<String> aliases = new LinkedHashSet<>();
 for (JsonNode aliasNode : aliasesNode) {
  if (!aliasNode.isTextual())
   throw new SchemaParseException("alias not a string: "+aliasNode);
  aliases.add(aliasNode.textValue());
 }
 return aliases;
}

代码示例来源:origin: actorapp/actor-platform

private static SchemeType loadType(JsonNode node) throws IOException {
  if (node.size() > 0) {
    String complexNode = node.get("type").textValue();
    if (complexNode.equals("list")) {
      return new SchemeListType(loadType(node.get("childType")));
    } else if (complexNode.equals("struct")) {
      return new SchemeStructType(node.get("childType").textValue());
    } else if (complexNode.equals("opt")) {
      return new SchemeOptionalType(loadType(node.get("childType")));
    } else if (complexNode.equals("enum")) {
      return new SchemeEnumType(node.get("childType").textValue());
    } else if (complexNode.equals("alias")) {
      return new SchemeAliasType(node.get("childType").textValue());
    } else if (complexNode.equals("trait")) {
      return new SchemeTraitType(node.get("childType").textValue());
    } else {
      throw new IOException();
    }
  } else {
    return new SchemePrimitiveType(node.textValue());
  }
}

代码示例来源:origin: line/armeria

/**
 * Returns a {@link JsonNode} which is converted from a {@link Response} object. The {@link JsonNode}
 * will be converted as JSON string by the {@link JacksonResponseConverterFunction}.
 */
@Post("/node/node")
public JsonNode json1(@RequestObject JsonNode input) {
  final JsonNode name = input.get("name");
  return mapper.valueToTree(new Response(Response.SUCCESS, name.textValue()));
}

代码示例来源:origin: knowm/XChange

@Override
 public KucoinActiveOrder deserialize(JsonParser p, DeserializationContext ctxt)
   throws IOException, JsonProcessingException {
  JsonNode root = p.readValueAsTree();
  if (root.isArray()) {
   Date timestamp = new Date(root.get(0).asLong());
   KucoinOrderType orderType = KucoinOrderType.valueOf(root.get(1).asText());
   BigDecimal price = root.get(2).decimalValue();
   BigDecimal amount = root.get(3).decimalValue();
   BigDecimal dealAmount = root.get(4).decimalValue(); // amount already filled
   String orderOid = root.get(5).textValue();
   return new KucoinActiveOrder(timestamp, orderType, price, amount, dealAmount, orderOid);
  } else {
   throw new RuntimeException("KucoinDealOrder should have an array as root node!");
  }
 }
}

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

private Object get(JsonNode result, String path) {
  String[] nodes = path.split("\\.");
  for (int i = 0; i < nodes.length - 1; i++) {
    String node = nodes[i];
    result = result.path(node);
  }
  return result.get(nodes[nodes.length - 1]).textValue();
}

代码示例来源:origin: line/armeria

/**
 * Returns a {@link Response} object. The {@link ProducesJson} annotation makes an object be converted
 * as JSON string by the {@link JacksonResponseConverterFunction}.
 */
@Post("/node/obj")
@ProducesJson
public Response json2(@RequestObject JsonNode input) {
  final JsonNode name = input.get("name");
  return new Response(Response.SUCCESS, name.textValue());
}

相关文章