本文整理了Java中com.fasterxml.jackson.databind.JsonNode.numberValue()
方法的一些代码示例,展示了JsonNode.numberValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.numberValue()
方法的具体详情如下:
包路径:com.fasterxml.jackson.databind.JsonNode
类名称:JsonNode
方法名:numberValue
[英]Returns numeric value for this node, if and only if this node is numeric ( #isNumber returns true); otherwise returns null
[中]返回此节点的数值,当且仅当此节点为数值时(#isNumber返回true);否则返回null
代码示例来源:origin: apache/kafka
private static Object convert(JsonNode value) {
if (value.isArray()) {
List<String> retvalList = new ArrayList<>();
for (JsonNode arrayElement : value)
retvalList.add(arrayElement.asText());
return retvalList;
}
return value.getNodeType() == JsonNodeType.NUMBER ? value.numberValue() : value.asText();
}
代码示例来源:origin: redisson/redisson
@Override
public Number getNumberValue() throws IOException, JsonParseException {
return currentNumericNode().numberValue();
}
代码示例来源:origin: prestodb/presto
private Object toValue(JsonNode node)
throws IOException
{
if (node.isTextual()) {
return node.asText();
}
else if (node.isNumber()) {
return node.numberValue();
}
else if (node.isBoolean()) {
return node.asBoolean();
}
else if (node.isBinary()) {
return node.binaryValue();
}
else {
throw new IllegalStateException("Unexpected range bound value: " + node);
}
}
}
代码示例来源:origin: Graylog2/graylog2-server
return null;
case NUMBER:
return read.numberValue();
case OBJECT:
return read;
代码示例来源:origin: redisson/redisson
@Override
public String getText()
{
if (_closed) {
return null;
}
// need to separate handling a bit...
switch (_currToken) {
case FIELD_NAME:
return _nodeCursor.getCurrentName();
case VALUE_STRING:
return currentNode().textValue();
case VALUE_NUMBER_INT:
case VALUE_NUMBER_FLOAT:
return String.valueOf(currentNode().numberValue());
case VALUE_EMBEDDED_OBJECT:
JsonNode n = currentNode();
if (n != null && n.isBinary()) {
// this will convert it to base64
return n.asText();
}
default:
return (_currToken == null) ? null : _currToken.asString();
}
}
代码示例来源:origin: rakam-io/rakam
createdAt = DateTimeUtils.parseTimestamp(o.getValue().isNumber() ? o.getValue().numberValue()
: o.getValue().textValue());
} catch (Exception e) {
代码示例来源:origin: io.burt/jmespath-jackson
@Override
public Number toNumber(JsonNode n) {
return n.numberValue();
}
代码示例来源:origin: burtcorp/jmespath-java
@Override
public Number toNumber(JsonNode n) {
return n.numberValue();
}
代码示例来源:origin: vmware/admiral
private static JsonElement getPrimitiveJsonElement(JsonNode node) {
if (node.isNull()) {
return JsonNull.INSTANCE;
} else if (node.isNumber()) {
return new JsonPrimitive(node.numberValue());
}
com.google.gson.JsonParser parser = new com.google.gson.JsonParser();
return parser.parse(node.asText());
}
代码示例来源:origin: com.eclipsesource.jaxrs/jersey-all
@Override
public Number getNumberValue() throws IOException, JsonParseException {
return currentNumericNode().numberValue();
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics
@Override
public Number getNumberValue() throws IOException, JsonParseException {
return currentNumericNode().numberValue();
}
代码示例来源:origin: hstaudacher/osgi-jax-rs-connector
@Override
public Number getNumberValue() throws IOException, JsonParseException {
return currentNumericNode().numberValue();
}
代码示例来源:origin: com.jwebmp.jackson.core/jackson-databind
@Override
public Number getNumberValue() throws IOException, JsonParseException {
return currentNumericNode().numberValue();
}
代码示例来源:origin: com.fasterxml.jackson.core/com.springsource.com.fasterxml.jackson.core.jackson-databind
@Override
public Number getNumberValue() throws IOException, JsonParseException {
return currentNumericNode().numberValue();
}
代码示例来源:origin: Nextdoor/bender
@Override
public Number getNumberValue() throws IOException, JsonParseException {
return currentNumericNode().numberValue();
}
代码示例来源:origin: io.projectreactor/reactor-bus
private Object unwrap(JsonNode node) {
if (node.isValueNode()) {
if (node.isNumber()) {
return node.numberValue();
} else if (node.isTextual()) {
return node.asText();
} else {
return node;
}
} else {
return node;
}
}
}
代码示例来源:origin: gofore/aws-training
@Override
public CompletableFuture<Message> apply(Message message) {
try {
JsonNode root = MAPPER.readTree(message.getBody());
String query = root.get("q").asText();
Optional<Long> limit = Optional.ofNullable(root.get("l").numberValue()).map(Number::longValue);
PageFinder pageFinder = new GoogleImagesFinder(query, limit);
Stream<String> pageUrls = pageFinder.findPageUrls();
return sequence(pageUrls.map(this::sendUrl)).thenApply(s -> message);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
代码示例来源:origin: com.github.tomakehurst/wiremock-jre8
private static Object getValue(JsonNode node) {
return node.isTextual() ? node.textValue() :
node.isNumber() ? node.numberValue() :
node.isBoolean() ? node.booleanValue() : node.textValue();
}
}
代码示例来源:origin: com.reprezen.jsonoverlay/jsonoverlay
@Override
protected Object _fromJson(JsonNode json) {
if (json.isTextual()) {
return json.textValue();
} else if (json.isNumber()) {
return json.numberValue();
} else if (json.isBoolean()) {
return json.booleanValue();
} else {
return null;
}
}
代码示例来源:origin: com.hubspot.rosetta/RosettaCore
private Object unwrapJsonValue(JsonNode node) {
if (node.isNull()) {
return null;
} else if (node.isBoolean()) {
return node.booleanValue();
} else if (node.isBinary()) {
return ((BinaryNode) node).binaryValue();
} else if (node.isNumber()) {
return node.numberValue();
} else {
return node.asText();
}
}
}
内容来源于网络,如有侵权,请联系作者删除!