本文整理了Java中com.fasterxml.jackson.databind.JsonNode.shortValue()
方法的一些代码示例,展示了JsonNode.shortValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.shortValue()
方法的具体详情如下:
包路径:com.fasterxml.jackson.databind.JsonNode
类名称:JsonNode
方法名:shortValue
[英]Returns 16-bit short value for this node, if and only if this node is numeric ( #isNumber returns true). For other types returns 0. For floating-point numbers, value is truncated using default Java coercion, similar to how cast from double to short operates.
[中]返回此节点的16位短值,当且仅当此节点为数字时(#isNumber返回true)。对于其他类型,返回0。对于浮点数,使用默认Java强制截断值,类似于从double到short的转换操作。
代码示例来源:origin: org.springframework.boot/spring-boot
return (D) Short.valueOf(jsonNode.shortValue());
代码示例来源:origin: apache/hive
return new ByteWritable((byte) value.intValue());
case SHORT:
return (new ShortWritable(value.shortValue()));
case INT:
return new IntWritable(value.intValue());
代码示例来源:origin: io.confluent.kafka/connect-utils
@Override
public Object parseJsonNode(JsonNode input, Schema schema) {
Preconditions.checkState(input.isInt(), "'%s' is not a '%s'", input.textValue(), expectedClass().getSimpleName());
return input.shortValue();
}
}
代码示例来源:origin: com.github.jcustenborder.kafka.connect/connect-utils
@Override
public Object parseJsonNode(JsonNode input, Schema schema) {
Object result;
if (input.isNumber()) {
result = input.shortValue();
} else if (input.isTextual()) {
result = parseString(input.textValue(), schema);
} else {
throw new UnsupportedOperationException(
String.format(
"Could not parse '%s' to %s",
input,
this.expectedClass().getSimpleName()
)
);
}
return result;
}
}
代码示例来源:origin: lianggzone/netty-im
@Override
protected void decode(ChannelHandlerContext channelHandlerContext, TextWebSocketFrame textWebSocketFrame, List<Object> list) throws Exception {
String text = textWebSocketFrame.text();
JsonNode root = jsonMapper.readTree(text);
ProtocolModel protocolModel = new ProtocolModel();
if (root.has("version")) {
protocolModel.setVersion(root.get("version").shortValue());
}
if (root.has("commandId")) {
protocolModel.setCommandId(root.get("commandId").asInt());
}
if (root.has("seqId")) {
protocolModel.setSeqId(root.get("seqId").asInt());
}
if (root.has("shellId")) {
protocolModel.setShellId(root.get("shellId").asLong());
}
if (root.has("body")) {
protocolModel.setBody(root.get("body").toString().getBytes());
}
list.add(protocolModel);
}
}
代码示例来源:origin: org.graylog.jest/jest-common
Object o = id.shortValue();
return (T) o;
代码示例来源:origin: kite-sdk/kite
list.add(datum.asLong());
} else if (datum.isShort()) {
list.add(datum.shortValue());
} else if (datum.isDouble()) {
list.add(datum.asDouble());
代码示例来源:origin: org.kitesdk/kite-morphlines-json
list.add(datum.asLong());
} else if (datum.isShort()) {
list.add(datum.shortValue());
} else if (datum.isDouble()) {
list.add(datum.asDouble());
代码示例来源:origin: com.cloudera.cdk/cdk-morphlines-json
list.add(datum.asLong());
} else if (datum.isShort()) {
list.add(datum.shortValue());
} else if (datum.isDouble()) {
list.add(datum.asDouble());
代码示例来源:origin: com.xiaomi.infra.galaxy/galaxy-olap-sdk-java
public Object get(String key) {
JsonNode node = map.get(key);
if (node instanceof NullNode) {
return null;
} else if (node instanceof ShortNode) {
return node.shortValue();
} else if (node instanceof IntNode) {
return node.intValue();
} else if (node instanceof LongNode) {
return node.longValue();
} else if (node instanceof FloatNode) {
return node.floatValue();
} else if (node instanceof DoubleNode) {
return node.doubleValue();
} else if (node instanceof TextNode) {
return node.textValue();
} else if (node instanceof BooleanNode) {
return node.booleanValue();
}else{
return node.asText();
}
}
}
代码示例来源:origin: com.blackducksoftware.magpie/magpie-test
/**
* Unwraps a JSON node as an object.
*/
@Nullable
static Object unwrap(@Nullable JsonNode node) {
if (node == null) {
return null;
} else if (node.isArray()) {
return StreamSupport.stream(node.spliterator(), false)
.map(JsonUtil::unwrap).collect(Collectors.toList());
} else if (node.isBoolean()) {
return node.booleanValue();
} else if (node.isDouble()) {
return node.doubleValue();
} else if (node.isFloat()) {
return node.floatValue();
} else if (node.isShort()) {
return node.shortValue();
} else if (node.isInt()) {
return node.intValue();
} else if (node.isLong()) {
return node.longValue();
} else if (node.isTextual()) {
return node.asText();
} else if (node.isNull()) {
return null;
} else {
return node;
}
}
代码示例来源:origin: com.cloudera.cdk/cdk-morphlines-json
record.put(fieldName, datum.asLong());
} else if (datum.isShort()) {
record.put(fieldName, datum.shortValue());
} else if (datum.isDouble()) {
record.put(fieldName, datum.asDouble());
代码示例来源:origin: kite-sdk/kite
record.put(fieldName, datum.asLong());
} else if (datum.isShort()) {
record.put(fieldName, datum.shortValue());
} else if (datum.isDouble()) {
record.put(fieldName, datum.asDouble());
代码示例来源:origin: org.kitesdk/kite-morphlines-json
record.put(fieldName, datum.asLong());
} else if (datum.isShort()) {
record.put(fieldName, datum.shortValue());
} else if (datum.isDouble()) {
record.put(fieldName, datum.asDouble());
代码示例来源:origin: org.apache.hive/kafka-handler
return new ByteWritable((byte) value.intValue());
case SHORT:
return (new ShortWritable(value.shortValue()));
case INT:
return new IntWritable(value.intValue());
代码示例来源: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;
}
}
代码示例来源:origin: io.atlasmap/atlas-json-core
private Object handleNumberNode(JsonNode valueNode, JsonField jsonField) {
if (valueNode.isInt()) {
jsonField.setFieldType(FieldType.INTEGER);
return valueNode.intValue();
} else if (valueNode.isDouble()) {
jsonField.setFieldType(FieldType.DOUBLE);
return valueNode.doubleValue();
} else if (valueNode.isBigDecimal()) {
jsonField.setFieldType(FieldType.DECIMAL);
return valueNode.decimalValue();
} else if (valueNode.isFloat()) {
jsonField.setFieldType(FieldType.DOUBLE);
return valueNode.floatValue();
} else if (valueNode.isLong()) {
jsonField.setFieldType(FieldType.LONG);
return valueNode.longValue();
} else if (valueNode.isShort()) {
jsonField.setFieldType(FieldType.SHORT);
return valueNode.shortValue();
} else if (valueNode.isBigInteger()) {
jsonField.setFieldType(FieldType.BIG_INTEGER);
return valueNode.bigIntegerValue();
} else {
jsonField.setFieldType(FieldType.NUMBER);
return valueNode.numberValue();
}
}
内容来源于网络,如有侵权,请联系作者删除!