本文整理汇总了Java中com.fasterxml.jackson.core.JsonTokenId.ID_NUMBER_FLOAT属性的典型用法代码示例。如果您正苦于以下问题:Java JsonTokenId.ID_NUMBER_FLOAT属性的具体用法?Java JsonTokenId.ID_NUMBER_FLOAT怎么用?Java JsonTokenId.ID_NUMBER_FLOAT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.fasterxml.jackson.core.JsonTokenId
的用法示例。
在下文中一共展示了JsonTokenId.ID_NUMBER_FLOAT属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeValue
private void writeValue(JsonRecord value) throws IOException {
switch (value.getKind()) {
case JsonTokenId.ID_STRING:
jg.writeString(value.getValue());
break;
case JsonTokenId.ID_NULL:
jg.writeNull();
break;
case JsonTokenId.ID_NUMBER_FLOAT:
case JsonTokenId.ID_NUMBER_INT:
jg.writeNumber(value.getValue());
break;
case JsonTokenId.ID_TRUE:
jg.writeBoolean(true);
break;
case JsonTokenId.ID_FALSE:
jg.writeBoolean(false);
break;
default:
}
}
示例2: deserialize
@Override
public Duration deserialize(JsonParser parser, DeserializationContext context) throws IOException {
switch (parser.getCurrentTokenId()) {
case JsonTokenId.ID_NUMBER_FLOAT:
BigDecimal value = parser.getDecimalValue();
long seconds = value.longValue();
int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds);
return Duration.ofSeconds(seconds, nanoseconds);
case JsonTokenId.ID_NUMBER_INT:
return Duration.ofSeconds(parser.getLongValue());
case JsonTokenId.ID_STRING:
String string = parser.getText().trim();
if (string.length() == 0) {
return null;
}
return Duration.parse(string);
}
throw context.mappingException("Expected type float, integer, or string.");
}
示例3: deserialize
@Override
public Duration deserialize(JsonParser parser, DeserializationContext context) throws IOException
{
switch (parser.currentTokenId())
{
case JsonTokenId.ID_NUMBER_FLOAT:
BigDecimal value = parser.getDecimalValue();
long seconds = value.longValue();
int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds);
return Duration.ofSeconds(seconds, nanoseconds);
case JsonTokenId.ID_NUMBER_INT:
if(context.isEnabled(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)) {
return Duration.ofSeconds(parser.getLongValue());
}
return Duration.ofMillis(parser.getLongValue());
case JsonTokenId.ID_STRING:
String string = parser.getText().trim();
if (string.length() == 0) {
return null;
}
try {
return Duration.parse(string);
} catch (DateTimeException e) {
return _rethrowDateTimeException(parser, context, e, string);
}
case JsonTokenId.ID_EMBEDDED_OBJECT:
// 20-Apr-2016, tatu: Related to [databind#1208], can try supporting embedded
// values quite easily
return (Duration) parser.getEmbeddedObject();
case JsonTokenId.ID_START_ARRAY:
return _deserializeFromArray(parser, context);
}
return _reportWrongToken(parser, context, JsonToken.VALUE_STRING,
JsonToken.VALUE_NUMBER_INT, JsonToken.VALUE_NUMBER_FLOAT);
}
示例4: parseDocument
public void parseDocument(ElementHandler docHandler)
throws IOException {
push(docHandler);
JsonToken tkn = parser.nextToken();
while (null != tkn) {
switch(tkn.id()) {
case JsonTokenId.ID_START_OBJECT:
ElementHandler newHandler = top().newObject();
push(newHandler);
break;
case JsonTokenId.ID_END_OBJECT:
ElementHandler endHandler = top();
endHandler.endObject();
pop();
break;
case JsonTokenId.ID_FIELD_NAME:
ElementHandler fieldHandler = top();
fieldHandler.fieldName(parser.getText());
break;
case JsonTokenId.ID_START_ARRAY:
top().newArray();
break;
case JsonTokenId.ID_END_ARRAY:
top().endArray();
break;
case JsonTokenId.ID_STRING:
top().withString(parser.getText());
break;
case JsonTokenId.ID_NUMBER_INT:
top().withBigInteger(parser.getBigIntegerValue());
break;
case JsonTokenId.ID_NUMBER_FLOAT:
top().withBigDecimal(parser.getDecimalValue());
break;
case JsonTokenId.ID_TRUE:
top().withBoolean(true);
break;
case JsonTokenId.ID_FALSE:
top().withBoolean(false);
break;
case JsonTokenId.ID_NULL:
top().withNull();
break;
default:
PushJsonLogger.LOG.warn(fmtToken(tkn, parser.getText()));
break;
}
// Keep going
tkn = parser.nextToken();
}
}