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

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

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

JsonNode.isTextual介绍

暂无

代码示例

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

/** Return the defined properties that have string values. */
@Deprecated public Map<String,String> getProps() {
 Map<String,String> result = new LinkedHashMap<String,String>();
 for (Map.Entry<String,JsonNode> e : props.entrySet())
  if (e.getValue().isTextual())
   result.put(e.getKey(), e.getValue().getTextValue());
 return result;
}

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

/**
 * Returns the value of the named, string-valued property in this schema.
 * Returns <tt>null</tt> if there is no string-valued property with that name.
 */
public String getProp(String name) {
 JsonNode value = getJsonProp(name);
 return value != null && value.isTextual() ? value.getTextValue() : null;
}

代码示例来源:origin: org.apache.avro/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<String>();
 for (JsonNode aliasNode : aliasesNode) {
  if (!aliasNode.isTextual())
   throw new SchemaParseException("alias not a string: "+aliasNode);
  aliases.add(aliasNode.getTextValue());
 }
 return aliases;
}

代码示例来源:origin: kaaproject/kaa

@Override
protected void customizeType(Record record, Schema fieldTypeSchema) {
 if (record != null && eventClassTypes.contains(record.getSchema().getName())) {
  JsonNode classTypeNode = fieldTypeSchema.getJsonProp(CLASS_TYPE);
  Schema enumSchema = record.getSchema().getField(CLASS_TYPE).schema();
  if (classTypeNode != null && classTypeNode.isTextual()) {
   record.put(CLASS_TYPE,
     new GenericData.EnumSymbol(enumSchema,
       classTypeNode.asText().toUpperCase()));
  } else {
   record.put(CLASS_TYPE, new GenericData.EnumSymbol(enumSchema, OBJECT));
  }
 }
}

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

} else if (node.isTextual()) {
 return node.asText();
} else if (node.isNumber()) {

代码示例来源:origin: kaaproject/kaa

@Override
protected void customizeFormField(Record fieldType, Field field) {
 if (fieldType.getSchema().getName().equals(ARRAY_FIELD_TYPE)) {
  JsonNode overrideStrategyNode = field.getJsonProp(OVERRIDE_STRATEGY);
  Schema overrideStrategySchema =
    fieldType.getSchema().getField(OVERRIDE_STRATEGY).schema();
  if (overrideStrategyNode != null && overrideStrategyNode.isTextual()) {
   fieldType.put(OVERRIDE_STRATEGY,
     new GenericData.EnumSymbol(
       overrideStrategySchema, overrideStrategyNode.asText().toUpperCase()));
  } else {
   fieldType.put(OVERRIDE_STRATEGY,
     new GenericData.EnumSymbol(
       overrideStrategySchema, OverrideStrategy.REPLACE.name()));
  }
 }
}

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

if(defaultJson.isTextual()) {
    break;
  break;
case STRING:
  if(!defaultJson.isTextual()) {
    expectedVal = "string";
  if(defaultJson.isTextual()) {
    if(schema.hasEnumSymbol(defaultJson.getTextValue())) {
      break;
  break;
case FIXED:
  if(defaultJson.isTextual()) {
    byte[] fixed = defaultJson.getValueAsText().getBytes();
    if(fixed.length == schema.getFixedSize()) {

代码示例来源:origin: kaaproject/kaa

if (!object.has(TYPE) || !object.get(TYPE).isTextual()
  || !object.get(TYPE).getTextValue().equals("record")) {
 throw new IllegalArgumentException("The data provided is not a record!");
if (!object.has(NAMESPACE) || !object.get(NAMESPACE).isTextual()) {
 throw new IllegalArgumentException("No namespace specified!");
} else if (!object.has(NAME) || !object.get(NAME).isTextual()) {
 throw new IllegalArgumentException("No name specified!");
} else {
} else {
 for (JsonNode child : object.get(DEPENDENCIES)) {
  if (!child.isObject() || !child.has(FQN) || !child.get(FQN).isTextual()
    || !child.has(VERSION) || !child.get(VERSION).isInt()) {
   throw new IllegalArgumentException("Illegal dependency format!");

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

case ENUM:
case FIXED:
 return defaultValue.isTextual();
case INT:
case LONG:

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

@Test
public void testToJson() throws IOException {
 GlobalMetadata m = new GlobalMetadata();
 m.addTransferEncoding("foo");
 m.addTransferEncoding("bar");
 byte[] utf8 = m.toJsonUtf8();
 String parsed = new String(utf8, StandardCharsets.UTF_8);
 JsonNode root = new ObjectMapper().readTree(parsed);
 Assert.assertTrue(root.isObject());
 Iterator<JsonNode> children = root.getElements();
 int numChildren = 0;
 while (children.hasNext()) {
  children.next();
  numChildren++;
 }
 Assert.assertEquals(numChildren, 3, "expected only 3 child nodes - file, dataset, id");
 Assert.assertEquals(root.get("file").size(), 0, "expected no children in file node");
 Assert.assertTrue(root.get("id").isTextual(), "expected ID to be textual");
 JsonNode transferEncoding = root.get("dataset").get("Transfer-Encoding");
 Assert.assertEquals(transferEncoding.size(), m.getTransferEncoding().size());
 for (int i = 0; i < m.getTransferEncoding().size(); i++) {
  Assert.assertEquals(transferEncoding.get(i).getTextValue(), m.getTransferEncoding().get(i));
 }
}

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

return (float) jsonNode.asDouble();
} else if (jsonNode.isTextual()) {
 if (schema == null || schema.getType().equals(Schema.Type.STRING) ||
   schema.getType().equals(Schema.Type.ENUM)) {

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

if (fieldNode.isTextual()) {
  return fieldNode.getTextValue();

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

if (schema.isTextual()) {                     // name
 Schema result = names.get(schema.getTextValue());
 if (result == null)
   if (fieldTypeNode == null)
    throw new SchemaParseException("No field type: "+field);
   if (fieldTypeNode.isTextual()
     && names.get(fieldTypeNode.getTextValue()) == null)
    throw new SchemaParseException
     && (Type.FLOAT.equals(fieldSchema.getType())
       || Type.DOUBLE.equals(fieldSchema.getType()))
     && defaultValue.isTextual())
    defaultValue =
     new DoubleNode(Double.valueOf(defaultValue.getTextValue()));

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

if (fieldNode.isTextual()) {
  return fieldNode.getTextValue();

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

break;
case FIXED:
 if (!n.isTextual())
  throw new AvroTypeException("Non-string default value for fixed: "+n);
 byte[] bb = n.getTextValue().getBytes("ISO-8859-1");
 break;
case STRING:
 if (!n.isTextual())
  throw new AvroTypeException("Non-string default value for string: "+n);
 e.writeString(n.getTextValue());
 break;
case BYTES:
 if (!n.isTextual())
  throw new AvroTypeException("Non-string default value for bytes: "+n);
 e.writeBytes(n.getTextValue().getBytes("ISO-8859-1"));

代码示例来源:origin: kaaproject/kaa

return byDefault.asLong();
if (byDefault.isTextual()) {
 Schema enumSchema = AvroUtils.getSchemaByType(schemaNode, Type.ENUM);
 if (enumSchema != null) {

代码示例来源:origin: klout/brickhouse

if (jsonNode.isTextual())
  return jsonNode.getTextValue();
else

代码示例来源:origin: org.apache.isis.viewer/isis-viewer-restfulobjects-applib

@Override
  public String apply(final JsonNode input) {
    if (!input.isTextual()) {
      throw new IllegalStateException("found node that is not a string " + input.toString());
    }
    return input.getTextValue();
  }
});

代码示例来源:origin: com.ngdata/hbase-indexer-common

public static String getString(JsonNode node, String prop) throws JsonFormatException {
  if (node.get(prop) == null || node.get(prop).isNull()) {
    throw new JsonFormatException("Missing required property: " + prop);
  }
  if (!node.get(prop).isTextual()) {
    throw new JsonFormatException("Not a string property: " + prop);
  }
  return node.get(prop).getTextValue();
}

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

private Object extractId(JsonNode idNode) {
    if (idNode == null)
      return null;

    if (idNode.isNumber())
      return idNode.getNumberValue();

    if (idNode.isTextual())
      return idNode.getTextValue();

    if (idNode.isNull())
      return null;

    throw new IllegalArgumentException("Not a valid id type: " + idNode);
  }
}

相关文章