本文整理匯總了Java中com.fasterxml.jackson.core.JsonParser.getValueAsBoolean方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonParser.getValueAsBoolean方法的具體用法?Java JsonParser.getValueAsBoolean怎麽用?Java JsonParser.getValueAsBoolean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.fasterxml.jackson.core.JsonParser
的用法示例。
在下文中一共展示了JsonParser.getValueAsBoolean方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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));
}
}
示例2: 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));
}
}