本文整理匯總了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));
}
}