本文整理了Java中org.codehaus.jackson.JsonNode.asDouble()
方法的一些代码示例,展示了JsonNode.asDouble()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.asDouble()
方法的具体详情如下:
包路径:org.codehaus.jackson.JsonNode
类名称:JsonNode
方法名:asDouble
[英]Method that will try to convert value of this node to a Java double. Numbers are coerced using default Java rules; booleans convert to 0.0 (false) and 1.0 (true), and Strings are parsed using default Java language integer parsing rules.
If representation can not be converted to an int (including structured types like Objects and Arrays), default value of 0.0 will be returned; no exceptions are thrown.
[中]方法,该方法将尝试将此节点的值转换为Java double。使用默认Java规则强制数字;布尔值转换为0.0(false)和1.0(true),字符串使用默认的Java语言整数解析规则进行解析。
如果表示不能转换为int(包括对象和数组等结构化类型),则返回默认值0.0;没有抛出异常。
代码示例来源:origin: org.codehaus.jackson/jackson-core-asl
/**
* Method that will try to convert value of this node to a Java <b>double</b>.
* Numbers are coerced using default Java rules; booleans convert to 0.0 (false)
* and 1.0 (true), and Strings are parsed using default Java language integer
* parsing rules.
*<p>
* If representation can not be converted to an int (including structured types
* like Objects and Arrays),
* default value of <b>0.0</b> will be returned; no exceptions are thrown.
*
* @since 1.9 (replaces <code>getValueAsDouble</code>)
*/
public double asDouble() {
return asDouble(0.0);
}
代码示例来源:origin: org.codehaus.jackson/jackson-core-asl
/**
* Method that will try to convert value of this node to a Java <b>double</b>.
* Numbers are coerced using default Java rules; booleans convert to 0.0 (false)
* and 1.0 (true), and Strings are parsed using default Java language integer
* parsing rules.
*<p>
* If representation can not be converted to an int (including structured types
* like Objects and Arrays),
* default value of <b>0.0</b> will be returned; no exceptions are thrown.
*
* @since 1.6
*
* @deprecated Since 1.9, use {@link #asDouble} instead
*/
@Deprecated
public double getValueAsDouble() { return asDouble(0.0); }
代码示例来源:origin: org.codehaus.jackson/jackson-core-asl
/**
* Method that will try to convert value of this node to a Java <b>double</b>.
* Numbers are coerced using default Java rules; booleans convert to 0.0 (false)
* and 1.0 (true), and Strings are parsed using default Java language integer
* parsing rules.
*<p>
* If representation can not be converted to an int (including structured types
* like Objects and Arrays),
* specified <b>defaultValue</b> will be returned; no exceptions are thrown.
*
* @since 1.6
*
* @deprecated Since 1.9, use {@link #asDouble} instead
*/
@Deprecated
public double getValueAsDouble(double defaultValue) { return asDouble(defaultValue); }
代码示例来源:origin: azkaban/azkaban
return node.asLong();
} else if (node.isDouble()) {
return node.asDouble();
} else {
System.err.println("ERROR What is this!? " + node.getNumberType());
代码示例来源:origin: org.apache.avro/avro
} else if (jsonNode.isDouble()) {
if (schema == null || schema.getType().equals(Schema.Type.DOUBLE)) {
return jsonNode.asDouble();
} else if (schema.getType().equals(Schema.Type.FLOAT)) {
return (float) jsonNode.asDouble();
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* Method that will try to convert value of this node to a Java <b>double</b>.
* Numbers are coerced using default Java rules; booleans convert to 0.0 (false)
* and 1.0 (true), and Strings are parsed using default Java language integer
* parsing rules.
*<p>
* If representation can not be converted to an int (including structured types
* like Objects and Arrays),
* default value of <b>0.0</b> will be returned; no exceptions are thrown.
*
* @since 1.9 (replaces <code>getValueAsDouble</code>)
*/
public double asDouble() {
return asDouble(0.0);
}
代码示例来源:origin: apache/hive
assertEquals("fcfs", pool2.get("schedulingPolicy").asText());
assertEquals(7, pool2.get("parallelism").asInt());
assertEquals(0.7, pool2.get("allocFraction").asDouble(), 0.00001);
assertTrue(pool2.get("triggers").isArray());
assertEquals(0, pool2.get("triggers").size());
assertEquals("fair", pool1.get("schedulingPolicy").asText());
assertEquals(3, pool1.get("parallelism").asInt());
assertEquals(0.3, pool1.get("allocFraction").asDouble(), 0.00001);
assertTrue(pool1.get("triggers").isArray());
assertEquals(1, pool1.get("triggers").size());
代码示例来源:origin: kaaproject/kaa
return byDefault.asDouble();
} else if (AvroUtils.getSchemaByType(schemaNode, Type.FLOAT) != null) {
return (float) byDefault.asDouble();
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* Method that will try to convert value of this node to a Java <b>double</b>.
* Numbers are coerced using default Java rules; booleans convert to 0.0 (false)
* and 1.0 (true), and Strings are parsed using default Java language integer
* parsing rules.
*<p>
* If representation can not be converted to an int (including structured types
* like Objects and Arrays),
* specified <b>defaultValue</b> will be returned; no exceptions are thrown.
*
* @since 1.6
*
* @deprecated Since 1.9, use {@link #asDouble} instead
*/
@Deprecated
public double getValueAsDouble(double defaultValue) { return asDouble(defaultValue); }
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* Method that will try to convert value of this node to a Java <b>double</b>.
* Numbers are coerced using default Java rules; booleans convert to 0.0 (false)
* and 1.0 (true), and Strings are parsed using default Java language integer
* parsing rules.
*<p>
* If representation can not be converted to an int (including structured types
* like Objects and Arrays),
* default value of <b>0.0</b> will be returned; no exceptions are thrown.
*
* @since 1.6
*
* @deprecated Since 1.9, use {@link #asDouble} instead
*/
@Deprecated
public double getValueAsDouble() { return asDouble(0.0); }
代码示例来源:origin: com.atlassian.jira/jira-core
public double asDouble()
{
return delegate.asDouble();
}
代码示例来源:origin: com.atlassian.jira/jira-core
public double asDouble(final double defaultValue)
{
return delegate.asDouble(defaultValue);
}
代码示例来源:origin: io.snamp/json-helpers
@Override
protected FloatBuffer deserialize(final ArrayNode input) throws JsonProcessingException {
final FloatBuffer result = FloatBuffer.allocate(input.size());
for(final JsonNode node: input)
result.put((float) node.asDouble());
return result;
}
}
代码示例来源:origin: mobi.boilr/libdynticker
@Override
public String parseTicker(JsonNode node, Pair pair) throws IOException,
NoMarketDataException {
for(JsonNode n : node.get("quotes")){
if(n.get("ticker").asText().toUpperCase().equals(pair.getCoin()) &&
n.get("base").asText().toUpperCase().equals(pair.getExchange())){
if(pair.getExchange().equals("USD") || pair.getExchange().equals("CAD"))
return Double.toString(n.get("last").asDouble()/100);
else
return Double.toString(n.get("last").asDouble()/1000000);
}
}
throw new NoMarketDataException(pair);
}
代码示例来源:origin: io.snamp/json-helpers
@Override
protected DoubleBuffer deserialize(final ArrayNode input) throws JsonProcessingException {
final DoubleBuffer result = DoubleBuffer.allocate(input.size());
for(final JsonNode node: input)
result.put(node.asDouble());
return result;
}
}
代码示例来源:origin: sirensolutions/siren
@Override
Float parse() throws ParseException {
final JsonNode value = node.path(BOOST_PROPERTY);
if (value.isFloatingPointNumber()) {
return (float) value.asDouble();
}
throw new ParseException("Invalid property '" + BOOST_PROPERTY + "': value is not a float");
}
代码示例来源:origin: rdelbru/SIREn
@Override
Float parse() throws ParseException {
final JsonNode value = node.path(BOOST_PROPERTY);
if (value.isFloatingPointNumber()) {
return (float) value.asDouble();
}
throw new ParseException("Invalid property '" + BOOST_PROPERTY + "': value is not a float");
}
代码示例来源:origin: de.agilecoders.wicket/bootstrap
@Test
public void parseReturnsCorrectJsonNode() throws Exception {
JsonNode jsonNode = Json.parse(JSON_STRING);
assertThat(jsonNode.get("key").asText(), is(equalTo("value")));
assertThat(jsonNode.get("1").asText(), is(equalTo("value2")));
assertThat(jsonNode.get("3").asBoolean(), is(equalTo(true)));
assertThat(jsonNode.get("double").asDouble(), is(equalTo(1.2)));
assertThat(jsonNode.get("").asText(), is(equalTo("null")));
}
代码示例来源:origin: de.agilecoders.wicket/bootstrap
@Test
public void parseNonStandardJsonReturnsCorrectJsonNode() throws Exception {
JsonNode jsonNode = Json.parse(NONSTANDARD_JSON_STRING);
assertThat(jsonNode.get("key").asText(), is(equalTo("value")));
assertThat(jsonNode.get("1").asText(), is(equalTo("value2")));
assertThat(jsonNode.get("3").asBoolean(), is(equalTo(true)));
assertThat(jsonNode.get("double").asDouble(), is(equalTo(1.2)));
assertThat(jsonNode.get("").asText(), is(equalTo("null")));
}
代码示例来源:origin: de.agilecoders.wicket/bootstrap
@Test
public void toJsonCreatesValidJsonNode() throws Exception {
JsonNode jsonNode = Json.toJson(createData());
assertThat(jsonNode.get("key").asText(), is(equalTo("value")));
assertThat(jsonNode.get("1").asText(), is(equalTo("value2")));
assertThat(jsonNode.get("3").asBoolean(), is(equalTo(true)));
assertThat(jsonNode.get("double").asDouble(), is(equalTo(1.2)));
assertThat(jsonNode.get("").asText(), is(equalTo("null")));
}
内容来源于网络,如有侵权,请联系作者删除!