本文整理了Java中com.fasterxml.jackson.databind.JsonNode.isFloat()
方法的一些代码示例,展示了JsonNode.isFloat()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.isFloat()
方法的具体详情如下:
包路径:com.fasterxml.jackson.databind.JsonNode
类名称:JsonNode
方法名:isFloat
暂无
代码示例来源:origin: Graylog2/graylog2-server
} else if (valueType == ValueType.DOUBLE && value.isDouble()) {
return ValueReference.of(value.doubleValue());
} else if (valueType == ValueType.FLOAT && value.isFloat()) {
return ValueReference.of(value.floatValue());
} else if (valueType == ValueType.INTEGER && value.isInt()) {
代码示例来源:origin: org.apache.beam/beam-sdks-java-core
/**
* Extracts float value from JsonNode if it is within bounds.
*
* <p>Throws {@link UnsupportedRowJsonException} if value is out of bounds.
*/
static ValueExtractor<Float> floatValueExtractor() {
return ValidatingValueExtractor.<Float>builder()
.setExtractor(JsonNode::floatValue)
.setValidator(
jsonNode ->
jsonNode.isFloat()
// Either floating number which allows lossless conversion to float
|| (jsonNode.isFloatingPointNumber()
&& jsonNode.doubleValue() == (double) (float) jsonNode.doubleValue())
// Or an integer number which allows lossless conversion to float
|| (jsonNode.isIntegralNumber()
&& jsonNode.canConvertToInt()
&& jsonNode.asInt() == (int) (float) jsonNode.asInt()))
.build();
}
代码示例来源:origin: apache/avro
} else if (jsonNode.isDouble() || jsonNode.isFloat()) {
if (schema == null || schema.getType().equals(Schema.Type.DOUBLE)) {
return jsonNode.asDouble();
代码示例来源:origin: json-path/JsonPath
} else if (e.isDouble()) {
return e.doubleValue();
} else if (e.isFloat()) {
return e.floatValue();
} else if (e.isBigDecimal()) {
代码示例来源:origin: rakam-io/rakam
private String getPostgresqlType(JsonNode clazz) {
if (clazz.isTextual()) {
try {
DateTimeUtils.parseDate(clazz.asText());
return "date";
} catch (Exception e) {
}
try {
DateTimeUtils.parseTimestamp(clazz.asText());
return "timestamp";
} catch (Exception e) {
}
return "text";
} else if (clazz.isFloat() || clazz.isDouble()) {
return "float8";
} else if (clazz.isNumber()) {
return "int8";
} else if (clazz.isBoolean()) {
return "bool";
} else if (clazz.isArray()) {
if(clazz.get(0).isObject()){
return "jsonb";
}
return getPostgresqlType(clazz.get(0)) + "[]";
} else if (clazz.isObject()) {
return "jsonb";
} else {
throw new IllegalArgumentException();
}
}
代码示例来源:origin: com.jayway.jsonpath/json-path
} else if (e.isDouble()) {
return e.doubleValue();
} else if (e.isFloat()) {
return e.floatValue();
} else if (e.isBigDecimal()) {
代码示例来源:origin: net.thisptr/jackson-jq
private static boolean test(final JsonNode value) {
if ((value.isDouble() || value.isFloat()) && Double.isNaN(value.asDouble()))
return true;
return false;
}
}
代码示例来源:origin: eiiches/jackson-jq
private static boolean test(final JsonNode value) {
if ((value.isDouble() || value.isFloat()) && Double.isNaN(value.asDouble()))
return true;
return false;
}
}
代码示例来源:origin: net.thisptr/jackson-jq
private static boolean test(final JsonNode value) {
if ((value.isDouble() || value.isFloat()) && Double.isInfinite(value.asDouble()))
return true;
return false;
}
}
代码示例来源:origin: eiiches/jackson-jq
private static boolean test(final JsonNode value) {
if ((value.isDouble() || value.isFloat()) && Double.isInfinite(value.asDouble()))
return true;
return false;
}
}
代码示例来源:origin: io.confluent.kafka/connect-utils
@Override
public Object parseJsonNode(JsonNode input, Schema schema) {
Preconditions.checkState(input.isFloat() || input.isDouble(), "'%s' is not a '%s'", input.asText(), expectedClass().getSimpleName());
return input.decimalValue().doubleValue();
}
}
代码示例来源:origin: io.confluent.kafka/connect-utils
@Override
public Object parseJsonNode(JsonNode input, Schema schema) {
Preconditions.checkState(input.isFloat() || input.isDouble(), "'%s' is not a '%s'", input.asText(), expectedClass().getSimpleName());
return input.decimalValue().floatValue();
}
}
代码示例来源:origin: walkmod/walkmod-core
public Map<String, Object> getParams(JsonNode next) {
if (next.has("params")) {
Iterator<Entry<String, JsonNode>> it2 = next.get("params").fields();
Map<String, Object> params = new HashMap<String, Object>();
while (it2.hasNext()) {
Entry<String, JsonNode> param = it2.next();
JsonNode value = param.getValue();
if (value.isTextual()) {
params.put(param.getKey(), value.asText());
} else if (value.isInt()) {
params.put(param.getKey(), value.asInt());
} else if (value.isBoolean()) {
params.put(param.getKey(), value.asBoolean());
} else if (value.isDouble() || value.isFloat() || value.isBigDecimal()) {
params.put(param.getKey(), value.asDouble());
} else if (value.isLong() || value.isBigInteger()) {
params.put(param.getKey(), value.asLong());
} else {
params.put(param.getKey(), value);
}
params.put(param.getKey(), param.getValue().asText());
}
return params;
}
return null;
}
代码示例来源:origin: org.walkmod/walkmod-core
public Map<String, Object> getParams(JsonNode next) {
if (next.has("params")) {
Iterator<Entry<String, JsonNode>> it2 = next.get("params").fields();
Map<String, Object> params = new HashMap<String, Object>();
while (it2.hasNext()) {
Entry<String, JsonNode> param = it2.next();
JsonNode value = param.getValue();
if (value.isTextual()) {
params.put(param.getKey(), value.asText());
} else if (value.isInt()) {
params.put(param.getKey(), value.asInt());
} else if (value.isBoolean()) {
params.put(param.getKey(), value.asBoolean());
} else if (value.isDouble() || value.isFloat() || value.isBigDecimal()) {
params.put(param.getKey(), value.asDouble());
} else if (value.isLong() || value.isBigInteger()) {
params.put(param.getKey(), value.asLong());
} else {
params.put(param.getKey(), value);
}
params.put(param.getKey(), param.getValue().asText());
}
return params;
}
return null;
}
代码示例来源:origin: amplab/succinct
private DataType getNodeType(JsonNode node) {
if (node.isTextual()) {
return DataType.STRING;
} else if (node.isBoolean()) {
return DataType.BOOLEAN;
} else if (node.isInt()) {
return DataType.INT;
} else if (node.isLong()) {
return DataType.LONG;
} else if (node.isFloat()) {
return DataType.FLOAT;
} else if (node.isDouble()) {
return DataType.DOUBLE;
} else {
throw new UnsupportedOperationException("JSON DataType not supported.");
}
}
}
代码示例来源:origin: com.almis.awe/awe-model
/**
* Constructor
*
* @param value Parameter value
*/
@JsonCreator
public QueryParameter(JsonNode value) {
this.value = value;
this.isList = value.isArray();
if (value.isInt()) {
this.type = ParameterType.INTEGER;
} else if (value.isLong()) {
this.type = ParameterType.LONG;
} else if (value.isFloat()) {
this.type = ParameterType.FLOAT;
} else if (value.isDouble()) {
this.type = ParameterType.DOUBLE;
} else if (value.isBoolean()) {
this.type = ParameterType.BOOLEAN;
} else if (value.isNull()) {
this.type = ParameterType.NULL;
} else {
this.type = ParameterType.STRING;
}
}
代码示例来源:origin: org.apache.olingo/odata-client-core
private EdmPrimitiveTypeKind guessPrimitiveTypeKind(final JsonNode node) {
return node.isShort() ? EdmPrimitiveTypeKind.Int16 :
node.isInt() ? EdmPrimitiveTypeKind.Int32 :
node.isLong() ? EdmPrimitiveTypeKind.Int64 :
node.isBoolean() ? EdmPrimitiveTypeKind.Boolean :
node.isFloat() ? EdmPrimitiveTypeKind.Single :
node.isDouble() ? EdmPrimitiveTypeKind.Double :
node.isBigDecimal() ? EdmPrimitiveTypeKind.Decimal :
EdmPrimitiveTypeKind.String;
}
代码示例来源:origin: apache/olingo-odata4
private EdmPrimitiveTypeKind guessPrimitiveTypeKind(final JsonNode node) {
return node.isShort() ? EdmPrimitiveTypeKind.Int16 :
node.isInt() ? EdmPrimitiveTypeKind.Int32 :
node.isLong() ? EdmPrimitiveTypeKind.Int64 :
node.isBoolean() ? EdmPrimitiveTypeKind.Boolean :
node.isFloat() ? EdmPrimitiveTypeKind.Single :
node.isDouble() ? EdmPrimitiveTypeKind.Double :
node.isBigDecimal() ? EdmPrimitiveTypeKind.Decimal :
EdmPrimitiveTypeKind.String;
}
代码示例来源:origin: liveoak-io/liveoak
private RelationalOperand parseRelationalOperand(JsonNode node) {
Object value;
if (node.isTextual()) {
value = node.textValue();
} else if (node.isBoolean()) {
value = node.booleanValue();
} else if (node.isInt()) {
value = node.intValue();
} else if (node.isLong()) {
value = node.longValue();
} else if (node.isBigInteger()) {
value = node.bigIntegerValue();
} else if (node.isFloat()) {
value = node.floatValue();
} else if (node.isDouble()) {
value = node.doubleValue();
} else if (node.isBigDecimal()) {
value = node.decimalValue();
} else if (node.isNull()) {
value = null;
} else {
throw new IllegalArgumentException("Unexpected value of: " + node);
}
return new Value(value);
}
代码示例来源:origin: com.reprezen.jsonoverlay/jsonoverlay
@Override
protected Number _fromJson(JsonNode json) {
if (json.isBigDecimal()) {
return json.decimalValue();
} else if (json.isBigInteger()) {
return json.bigIntegerValue();
}
// no methods for Byte, even though numberNode(Byte) is provided.
// experimentations shows that bytes show up as ints. Oh well..
else if (json.isDouble()) {
return json.doubleValue();
} else if (json.isFloat()) {
return json.floatValue();
} else if (json.isInt()) {
return json.intValue();
} else if (json.isLong()) {
return json.longValue();
} else if (json.isShort()) {
return json.shortValue();
} else {
return null;
}
}
内容来源于网络,如有侵权,请联系作者删除!