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