本文整理了Java中com.fasterxml.jackson.databind.JsonNode.isDouble()
方法的一些代码示例,展示了JsonNode.isDouble()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.isDouble()
方法的具体详情如下:
包路径:com.fasterxml.jackson.databind.JsonNode
类名称:JsonNode
方法名:isDouble
暂无
代码示例来源:origin: apache/pulsar
@Override
public Object getField(String fieldName) {
JsonNode fn = jn.get(fieldName);
if (fn.isContainerNode()) {
AtomicInteger idx = new AtomicInteger(0);
List<Field> fields = Lists.newArrayList(fn.fieldNames())
.stream()
.map(f -> new Field(f, idx.getAndIncrement()))
.collect(Collectors.toList());
return new GenericJsonRecord(fields, fn);
} else if (fn.isBoolean()) {
return fn.asBoolean();
} else if (fn.isInt()) {
return fn.asInt();
} else if (fn.isFloatingPointNumber()) {
return fn.asDouble();
} else if (fn.isDouble()) {
return fn.asDouble();
} else {
return fn.asText();
}
}
}
代码示例来源:origin: Activiti/Activiti
} else if (resultNode.isLong()) {
result = resultNode.asLong();
} else if (resultNode.isBigDecimal() || resultNode.isDouble()) {
result = resultNode.asDouble();
} else if (resultNode.isTextual()) {
代码示例来源:origin: Graylog2/graylog2-server
if (valueType == ValueType.BOOLEAN && value.isBoolean()) {
return ValueReference.of(value.booleanValue());
} else if (valueType == ValueType.DOUBLE && value.isDouble()) {
return ValueReference.of(value.doubleValue());
} else if (valueType == ValueType.FLOAT && value.isFloat()) {
代码示例来源:origin: graphhopper/graphhopper
@Override
public PathDetail deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
JsonNode pathDetail = jp.readValueAsTree();
if (pathDetail.size() != 3)
throw new JsonParseException(jp, "PathDetail array must have exactly 3 entries but was " + pathDetail.size());
JsonNode from = pathDetail.get(0);
JsonNode to = pathDetail.get(1);
JsonNode val = pathDetail.get(2);
PathDetail pd;
if (val.isBoolean())
pd = new PathDetail(val.asBoolean());
else if (val.isLong())
pd = new PathDetail(val.asLong());
else if (val.isInt())
pd = new PathDetail(val.asInt());
else if (val.isDouble())
pd = new PathDetail(val.asDouble());
else if (val.isTextual())
pd = new PathDetail(val.asText());
else
throw new JsonParseException(jp, "Unsupported type of PathDetail value " + pathDetail.getNodeType().name());
pd.setFirst(from.asInt());
pd.setLast(to.asInt());
return pd;
}
}
代码示例来源: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.isBigDecimal()) {
return e.decimalValue();
} else if (e.isDouble()) {
return e.doubleValue();
} else if (e.isFloat()) {
代码示例来源:origin: briandilley/jsonrpc4j
private Object parseId(JsonNode node) {
if (isNullNodeOrValue(node)) {
return null;
}
if (node.isDouble()) {
return node.asDouble();
}
if (node.isFloatingPointNumber()) {
return node.asDouble();
}
if (node.isInt()) {
return node.asInt();
}
if (node.isLong()) {
return node.asLong();
}
//TODO(donequis): consider parsing bigints
if (node.isIntegralNumber()) {
return node.asInt();
}
if (node.isTextual()) {
return node.asText();
}
throw new IllegalArgumentException("Unknown id type");
}
代码示例来源: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.isBigDecimal()) {
return e.decimalValue();
} else if (e.isDouble()) {
return e.doubleValue();
} else if (e.isFloat()) {
代码示例来源:origin: baidubce/bce-sdk-java
@JsonIgnore
@Deprecated
public boolean isDoubleTo() {
return to.isDouble();
}
代码示例来源:origin: baidubce/bce-sdk-java
@JsonIgnore
@Deprecated
public boolean isDoubleFrom() {
return from.isDouble();
}
代码示例来源:origin: org.n52.eventing-api/core
@Override
public Optional<Double> getParameterAsDouble(String key) {
JsonNode value = this.config.get(key);
if (value != null && value.isDouble()) {
return Optional.of(value.asDouble());
}
return Optional.empty();
}
代码示例来源: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: 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: eiiches/jackson-jq
private static boolean test(final JsonNode value) {
if ((value.isDouble() || value.isFloat()) && Double.isNaN(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().floatValue();
}
}
代码示例来源: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: 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: schibsted/jslt
@Test
public void testNowFunction() {
JsonNode now1 = execute("{}", "now()");
double now2 = System.currentTimeMillis();
long delta = 1000; // milliseconds of wriggle-room
assertTrue(now1.isDouble());
assertTrue("now1 (" + now1 + ") << now2 (" + now2 + ")",
(now1.asDouble() * 1000) < (now2 + delta));
assertTrue("now1 (" + now1 + ") >> now2 (" + now2 + ")",
(now1.asDouble() * 1000) > (now2 - delta));
}
内容来源于网络,如有侵权,请联系作者删除!