当前位置: 首页>>代码示例>>Java>>正文


Java JsonNode.isTextual方法代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.JsonNode.isTextual方法的典型用法代码示例。如果您正苦于以下问题:Java JsonNode.isTextual方法的具体用法?Java JsonNode.isTextual怎么用?Java JsonNode.isTextual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.fasterxml.jackson.databind.JsonNode的用法示例。


在下文中一共展示了JsonNode.isTextual方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addAssignProp

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public static void addAssignProp(JsonNode props) throws IOException, SQLException, DataAccessException {
    String name = props.get("scheme").asText();
    JsonNode propNode = props.findPath("properties");
    String propString = "";
    if (propNode.isArray()) {
        for (JsonNode p : propNode) {
            propString = propString + p.textValue() + ",";
        }
        propString = propString.substring(0, propString.length() - 1);
    } else if (propNode.isTextual()) {
        propString = propNode.textValue();
    } else {
        Logger.error("passed property neither a list or array");
        throw new IllegalArgumentException();
    }
    setProp("prop." + name, propString);
}
 
开发者ID:SirAeroWN,项目名称:premier-wherehows,代码行数:18,代码来源:PropertyDao.java

示例2: parse

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public static <T> Optional<T> parse(String fieldName, JsonNode node, Class<T> type) {
    JsonNode field = node.get(fieldName);
    T value = null;
    if (field != null && !field.isNull()) {
        if (type.equals(Long.class) && field.canConvertToLong()) {
            value = type.cast(field.asLong());
        }
        if (type.equals(Integer.class) && field.canConvertToInt()) {
            value = type.cast(field.asInt());
        }
        if (field.isTextual()) {
            value = type.cast(field.asText());
        }
        if (field.isDouble() || type.equals(Double.class)) {
            value = type.cast(field.asDouble());
        }
        if (field.isBoolean()) {
            value = type.cast(field.asBoolean());
        }
    }
    return Optional.ofNullable(value);
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:23,代码来源:SanitizingHelper.java

示例3: addSortListProp

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public static void addSortListProp(JsonNode props) throws IOException, SQLException, DataAccessException {
    String name = props.get("scheme").asText();
    JsonNode propNode = props.findPath("properties");
    String propString = "";
    if (propNode.isArray()) {
        for (JsonNode p : propNode) {
            propString = propString + p.textValue() + ",";
        }
        propString = propString.substring(0, propString.length() - 1);
    } else if (propNode.isTextual()) {
        propString = propNode.textValue();
    } else {
        Logger.error("passed property neither a list or array");
        throw new IllegalArgumentException();
    }
    setProp("prop.sortlist." + name, propString);
}
 
开发者ID:SirAeroWN,项目名称:premier-wherehows,代码行数:18,代码来源:PropertyDao.java

示例4: updateSortListProp

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public static void updateSortListProp(JsonNode props) throws IOException, SQLException, DataAccessException {
    String name = props.get("scheme").asText();
    JsonNode propNode = props.findPath("properties");
    String propString = recProp("prop.sortlist." + name) + ",";
    if (propNode.isArray()) {
        for (JsonNode p : propNode) {
            propString = propString + p.textValue() + ",";
        }
        propString = propString.substring(0, propString.length() - 1);
    } else if (propNode.isTextual()) {
        propString = propString + propNode.textValue();
    } else {
        Logger.error("passed property neither a list or array");
        throw new IllegalArgumentException();
    }
    chngProp("prop.sortlist." + name, propString);
}
 
开发者ID:SirAeroWN,项目名称:premier-wherehows,代码行数:18,代码来源:PropertyDao.java

示例5: getAliases

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
default Set<String> getAliases() {
    if (this instanceof Annotable) {
        JsonNode node = ((Annotable) this).getAnnotations().get(ALIASES);
        if (node == null) {
            node = ((Annotable) this).getAnnotations().get(ALIAS);
        }
        Set<String> set = Sets.newHashSet();
        if (node == null) {
            return set;
        } else {
            if (node.isTextual()) {
                set.add(node.textValue());
            } else if (node.isArray()) {
                Iterator<JsonNode> it = node.iterator();
                while (it.hasNext()) {
                    JsonNode val = it.next();
                    Preconditions.checkArgument(val.isTextual());
                    set.add(val.textValue());
                }
            }
            return set;
        }
    } else {
        throw new IllegalArgumentException("Not annotable, must override!");
    }
}
 
开发者ID:atlascon,项目名称:travny,代码行数:27,代码来源:Aliases.java

示例6: createKeyValuedColumnType

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * Create KeyValuedColumnType entity.
 * @param json JsonNode
 * @return KeyValuedColumnType entity
 */
private static KeyValuedColumnType createKeyValuedColumnType(JsonNode json) {
    BaseType keyType = BaseTypeFactory.getBaseTypeFromJson(json, Type.KEY.type());
    BaseType valueType = BaseTypeFactory.getBaseTypeFromJson(json, Type.VALUE.type());
    int min = 1;
    int max = 1;
    JsonNode node = json.get("min");
    if (node != null && node.isNumber()) {
        min = node.asInt();
    }
    node = json.get("max");
    if (node != null) {
        if (node.isNumber()) {
            max = node.asInt();
        } else if (node.isTextual() && "unlimited".equals(node.asText())) {
            max = Integer.MAX_VALUE;
        }
    }
    return new KeyValuedColumnType(keyType, valueType, min, max);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:ColumnTypeFactory.java

示例7: getElement

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * Return the field with name in JSON as a string, a boolean, a number or a node.
 *
 * @param json json
 * @param name node name
 * @return the field
 */
public static Object getElement(final JsonNode json, final String name) {
    if (json != null && name != null) {
        JsonNode node = json;
        for (String nodeName : name.split("\\.")) {
            if (node != null) {
                node = node.get(nodeName);
            }
        }
        if (node != null) {
            if (node.isNumber()) {
                return node.numberValue();
            } else if (node.isBoolean()) {
                return node.booleanValue();
            } else if (node.isTextual()) {
                return node.textValue();
            } else if (node.isNull()) {
                return null;
            } else {
                return node;
            }
        }
    }
    return null;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:32,代码来源:JsonHelper.java

示例8: fromJsonNode

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * json like "string" or json like {"type" : "string", "enum": ["set",
 * ["access", "native-tagged"]]}" for key or value.
 * @param type JsonNode
 */
private static BaseType fromJsonNode(JsonNode type) {
    if (type.isTextual()) {
        return fromTypeStr(type.asText());
    } else if (type.isObject() && type.has("type")) {
        String typeStr = type.get("type").asText();
        switch (typeStr) {
        case "boolean":
            return new BooleanBaseType();
        case "integer":
            return getIntegerBaseType(type);
        case "real":
            return getRealBaseType(type);
        case "string":
            return getStringBaseType(type);
        case "uuid":
            return getUuidBaseType(type);
        default:
            return null;
        }
    }
    return null;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:BaseTypeFactory.java

示例9: deserialize

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public IGeometry deserialize(JsonParser jsonParser,
                             DeserializationContext deserializationContext) throws IOException,
        JsonProcessingException {
    ObjectCodec objectCodec = jsonParser.getCodec();
    JsonNode node = objectCodec.readTree(jsonParser);
    Class<? extends IGeometry> geometryClass = null;
    if (node.isObject()) {
        Iterator<Entry<String, JsonNode>> elementsIterator = node.fields();
        while (elementsIterator.hasNext()) {
            Entry<String, JsonNode> element = elementsIterator.next();
            String name = element.getKey();
            if (registry.containsKey(name)) {
                geometryClass = registry.get(name);
                break;
            }
        }
    } else if (node.isTextual()) {
        String text = node.textValue();
        if (this.geometryMapper.isSimplePointFormat(text)) {
            return this.geometryMapper.readPoint(text);
        } else if (this.geometryMapper.isSimpleEnvelopeFormat(text)) {
            return this.geometryMapper.readEnvelope(text);
        }
    }

    if (geometryClass == null) {
        return null;
    }

    StringWriter writer = new StringWriter();
    this.objectMapper.writeValue(writer, node);
    writer.close();
    String json = writer.toString();
    return this.objectMapper.readValue(json, geometryClass);
}
 
开发者ID:Esri,项目名称:server-extension-java,代码行数:37,代码来源:GeometryDeserializer.java

示例10: fromJson

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public static Error fromJson(final JsonNode json) {
    final String error;
    if (json.has(Field.ERROR)) {
        final JsonNode errorJson = json.get(Field.ERROR);
        if (errorJson.isTextual()) {
            error = errorJson.asText();
        } else if (errorJson.isNumber()) {
            error = String.valueOf(errorJson.asInt());
        } else {
            throw new IllegalArgumentException("Unexpected data type of error.error");
        }
    } else {
        error = null;
    }

    final String reason;
    if (json.has(Field.REASON)) {
        reason = json.get(Field.REASON).asText();
    } else {
        reason = null;
    }

    final String details;
    if (json.has(Field.DETAILS)) {
        details = json.get(Field.DETAILS).asText();
    } else {
        details = null;
    }

    return new Error(error, reason, details);
}
 
开发者ID:jahirfiquitiva,项目名称:Android-DDP,代码行数:32,代码来源:Protocol.java

示例11: matches

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private MatchType matches(JsonNode datum, Schema schema) {
  switch (schema.getType()) {
  case RECORD:
    if (datum.isObject()) {
      return matchRecord(datum, schema);
    }
    break;
  case UNION:
    return resolveUnion(datum, schema.getTypes()).matchType;
  case MAP:
    if (datum.isObject()) {
      return matchMapValue(datum, schema);
    }
    break;
  case ARRAY:
    if (datum.isArray()) {
      return matchArrayElement(datum, schema);
    }
    break;
  case BOOLEAN:
    if (datum.isBoolean()) {
      return MatchType.FULL;
    }
    break;
  case FLOAT:
    if (datum.isDouble() && datum.doubleValue() >= -Float.MAX_VALUE && datum.doubleValue() <= Float.MAX_VALUE
        || datum.isLong()
            && datum.longValue() >= (long) -Float.MAX_VALUE
            && datum.longValue() <= (long) Float.MAX_VALUE
        || datum.isFloat()
        || datum.isInt()) {
      return MatchType.FULL;
    }
    break;
  case DOUBLE:
    if (datum.isDouble() || datum.isFloat() || datum.isLong() || datum.isInt()) {
      return MatchType.FULL;
    }
    break;
  case INT:
    if (datum.isInt()) {
      return MatchType.FULL;
    }
    break;
  case LONG:
    if (datum.isLong() || datum.isInt()) {
      return MatchType.FULL;
    }
    break;
  case STRING:
    if (datum.isTextual()) {
      return MatchType.FULL;
    }
    break;
  case ENUM:
    if (datum.isTextual() && schema.hasEnumSymbol(datum.textValue())) {
      return MatchType.FULL;
    }
    break;
  case BYTES:
  case FIXED:
    if (datum.isTextual()) {
      return MatchType.FULL;
    }
    break;
  case NULL:
    if (datum.isNull()) {
      return MatchType.FULL;
    }
    break;
  default: // unknown
    throw new IllegalArgumentException("Unsupported schema: " + schema);
  }
  return MatchType.NONE;
}
 
开发者ID:HotelsDotCom,项目名称:jasvorno,代码行数:76,代码来源:JasvornoConverter.java

示例12: getInfraProvider

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public String getInfraProvider() {

		JsonNode item = getInfrastructure().get( "provider" );
		if ( item != null && item.isTextual() ) {
			return item.asText();
		}
		return "Not Configured";
	}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:9,代码来源:ReleasePackage.java

示例13: getInfraCatalog

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public String getInfraCatalog() {

		JsonNode item = getInfrastructure().get( "catalog" );
		if ( item != null && item.isTextual() ) {
			return item.asText();
		}
		return "Not Configured";
	}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:9,代码来源:ReleasePackage.java

示例14: parseEnum

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public static <E extends Enum<E>> Optional<E> parseEnum(String fieldName, JsonNode node, Class<E> type) {
    JsonNode field = node.get(fieldName);
    if (field != null && field.isTextual()) {
        return Optional.of(Enum.valueOf(type, node.get(fieldName).asText()));
    }
    return Optional.empty();
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:8,代码来源:SanitizingHelper.java

示例15: parse

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public EnumNode parse(String nodeName, JsonNode jsonNode) {
    if (jsonNode == null) return null;
    JsonNode enumNode = jsonNode.get(JsonDataType.ENUM.getValue());
    if (enumNode == null) return null;

    Iterator<JsonNode> nodeIterator = enumNode.elements();
    while (nodeIterator.hasNext()) {
        JsonNode childNode = nodeIterator.next();
        if (isNullNode(childNode)) {
            // null is a valid value
            generator.addItem(null);
        } else {
            // Data type is unconstrained by the schema, but we only support primitive data types
            if (childNode.isInt()) {
                generator.addItem(childNode.intValue());
            } else if(childNode.isFloatingPointNumber()) {
                generator.addItem(childNode.doubleValue());
            } else if (childNode.isTextual()) {
                generator.addItem(childNode.textValue());
            } else if (childNode.isBoolean()) {
                generator.addItem(childNode.booleanValue());
            }
        }
    }
    return new EnumNode(nodeName, generator);
}
 
开发者ID:zezutom,项目名称:schematic,代码行数:28,代码来源:EnumParser.java


注:本文中的com.fasterxml.jackson.databind.JsonNode.isTextual方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。