本文整理汇总了Java中com.fasterxml.jackson.core.JsonParser.getValueAsDouble方法的典型用法代码示例。如果您正苦于以下问题:Java JsonParser.getValueAsDouble方法的具体用法?Java JsonParser.getValueAsDouble怎么用?Java JsonParser.getValueAsDouble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.core.JsonParser
的用法示例。
在下文中一共展示了JsonParser.getValueAsDouble方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseField
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public void parseField(SimpleGenericModel<T> instance, String fieldName, JsonParser jsonParser) throws IOException {
if ("date".equals(fieldName)) {
instance.date = getjava_util_Date_type_converter().parse(jsonParser);
} else if ("string".equals(fieldName)) {
instance.string = jsonParser.getValueAsString(null);
} else if ("test_double".equals(fieldName)) {
instance.testDouble = jsonParser.getValueAsDouble();
} else if ("test_double_obj".equals(fieldName)) {
instance.testDoubleObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Double.valueOf(jsonParser.getValueAsDouble());
} else if ("test_float".equals(fieldName)) {
instance.testFloat = (float)jsonParser.getValueAsDouble();
} else if ("test_float_obj".equals(fieldName)) {
instance.testFloatObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : new Float(jsonParser.getValueAsDouble());
} else if ("test_int".equals(fieldName)) {
instance.testInt = jsonParser.getValueAsInt();
} else if ("test_int_obj".equals(fieldName)) {
instance.testIntObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Integer.valueOf(jsonParser.getValueAsInt());
} else if ("test_long".equals(fieldName)) {
instance.testLong = jsonParser.getValueAsLong();
} else if ("test_long_obj".equals(fieldName)) {
instance.testLongObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Long.valueOf(jsonParser.getValueAsLong());
} else if ("test_string".equals(fieldName)) {
instance.testString = jsonParser.getValueAsString(null);
} else if ("test_t".equals(fieldName)) {
instance.testT = m84ClassJsonMapper.parse(jsonParser);
}
}
示例2: parseField
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public void parseField(MultipleFieldNamesModel instance, String fieldName, JsonParser jsonParser) throws IOException {
if ("possible_double_name_1".equals(fieldName) || "possible_double_name_2".equals(fieldName)) {
instance.testDouble = jsonParser.getValueAsDouble();
} else if ("possible_float_name_1".equals(fieldName) || "possible_float_name_2".equals(fieldName)){
instance.testFloat = (float)jsonParser.getValueAsDouble();
} else if ("possible_int_name_1".equals(fieldName) || "possible_int_name_2".equals(fieldName)){
instance.testInt = jsonParser.getValueAsInt();
} else if ("possible_long_name_1".equals(fieldName) || "possible_long_name_2".equals(fieldName)){
instance.testLong = jsonParser.getValueAsLong();
} else if ("possible_string_name_1".equals(fieldName) || "possible_string_name_2".equals(fieldName)){
instance.testString = jsonParser.getValueAsString(null);
}
}
示例3: parseField
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public void parseField(SimpleGenericModelWithExtends<T> instance, String fieldName, JsonParser jsonParser) throws IOException {
if ("date".equals(fieldName)) {
instance.date = getjava_util_Date_type_converter().parse(jsonParser);
} else if ("string".equals(fieldName)) {
instance.string = jsonParser.getValueAsString(null);
} else if ("test_double".equals(fieldName)) {
instance.testDouble = jsonParser.getValueAsDouble();
} else if ("test_double_obj".equals(fieldName)) {
instance.testDoubleObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Double.valueOf(jsonParser.getValueAsDouble());
} else if ("test_float".equals(fieldName)) {
instance.testFloat = (float)jsonParser.getValueAsDouble();
} else if ("test_float_obj".equals(fieldName)) {
instance.testFloatObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : new Float(jsonParser.getValueAsDouble());
} else if ("test_int".equals(fieldName)) {
instance.testInt = jsonParser.getValueAsInt();
} else if ("test_int_obj".equals(fieldName)) {
instance.testIntObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Integer.valueOf(jsonParser.getValueAsInt());
} else if ("test_long".equals(fieldName)) {
instance.testLong = jsonParser.getValueAsLong();
} else if ("test_long_obj".equals(fieldName)) {
instance.testLongObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Long.valueOf(jsonParser.getValueAsLong());
} else if ("test_string".equals(fieldName)) {
instance.testString = jsonParser.getValueAsString(null);
} else if ("test_t".equals(fieldName)) {
instance.testT = m84ClassJsonMapper.parse(jsonParser);
}
}
示例4: parse
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
private Object parse(JsonParser parser, DeserializationContext context) throws IOException, JsonProcessingException
{
final JsonToken currentToken = parser.getCurrentToken();
switch( currentToken )
{
case START_OBJECT:
final Map<String, Object> oe = new MapDeserialiser().deserialize(parser, context);
if( parser.getCurrentToken() != JsonToken.END_OBJECT )
{
throw context.mappingException("Should be on end object " + where(parser, context));
}
return oe;
case VALUE_FALSE:
case VALUE_TRUE:
return parser.getValueAsBoolean();
case VALUE_NUMBER_INT:
return parser.getValueAsInt();
case VALUE_NUMBER_FLOAT:
return parser.getValueAsDouble();
case VALUE_NULL:
return "null";
case VALUE_STRING:
return "\"" + parser.getText() + "\"";
case START_ARRAY:
final Object[] ae = parseArray(parser, context);
if( parser.getCurrentToken() != JsonToken.END_ARRAY )
{
throw context.mappingException("Should be on end array " + where(parser, context));
}
return ae;
case END_ARRAY:
case END_OBJECT:
// whoops
throw context.mappingException("Unexpected end object/array " + where(parser, context));
case FIELD_NAME:
case NOT_AVAILABLE:
throw context.mappingException("How? " + where(parser, context));
default:
throw context.mappingException("Unhandled token " + where(parser, context));
}
}
示例5: parse
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
private Object parse(JsonParser parser, DeserializationContext context) throws IOException, JsonProcessingException
{
final JsonToken currentToken = parser.getCurrentToken();
switch( currentToken )
{
case START_OBJECT:
final ObjectExpression oe = new ObjectExpressionDeserialiser().deserialize(parser, context);
if( parser.getCurrentToken() != JsonToken.END_OBJECT )
{
throw context.mappingException("Should be on end object " + where(parser, context));
}
return oe;
case VALUE_FALSE:
case VALUE_TRUE:
return new PrimitiveValueExpression(parser.getValueAsBoolean());
case VALUE_NUMBER_INT:
return new PrimitiveValueExpression(parser.getValueAsInt());
case VALUE_NUMBER_FLOAT:
return new PrimitiveValueExpression(parser.getValueAsDouble());
case VALUE_NULL:
return new NullExpression();
case VALUE_STRING:
return new StringExpression(parser.getText());
case START_ARRAY:
final ArrayExpression ae = parseArray(parser, context);
if( parser.getCurrentToken() != JsonToken.END_ARRAY )
{
throw context.mappingException("Should be on end array " + where(parser, context));
}
return ae;
case END_ARRAY:
case END_OBJECT:
// whoops
throw context.mappingException("Unexpected end object/array " + where(parser, context));
case FIELD_NAME:
case NOT_AVAILABLE:
throw context.mappingException("How? " + where(parser, context));
default:
throw context.mappingException("Unhandled token " + where(parser, context));
}
}