本文整理汇总了Java中com.fasterxml.jackson.core.JsonParser.getBooleanValue方法的典型用法代码示例。如果您正苦于以下问题:Java JsonParser.getBooleanValue方法的具体用法?Java JsonParser.getBooleanValue怎么用?Java JsonParser.getBooleanValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.core.JsonParser
的用法示例。
在下文中一共展示了JsonParser.getBooleanValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getValueFromFieldType
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
public static Object getValueFromFieldType(JsonParser parser, MinorType fieldType) throws IOException {
switch (fieldType) {
case BIGINT:
return parser.getLongValue();
case VARCHAR:
return parser.getValueAsString();
case FLOAT4:
return parser.getFloatValue();
case BIT:
return parser.getBooleanValue();
case LATE:
case NULL:
return null;
default:
throw new RuntimeException("Unexpected Field type to return value: " + fieldType.toString());
}
}
示例2: parse
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public Boolean parse(JsonParser jsonParser) throws IOException {
if (jsonParser.getCurrentToken() == JsonToken.VALUE_NULL) {
return null;
} else {
return jsonParser.getBooleanValue();
}
}
示例3: getValue
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Nullable
private static Object getValue(JsonParser jp) throws IOException {
switch (jp.currentToken()) {
case VALUE_FALSE:
case VALUE_TRUE:
return jp.getBooleanValue();
case VALUE_STRING:
return jp.getValueAsString();
case VALUE_NUMBER_INT:
switch (jp.getNumberType()) {
case INT:
return jp.getIntValue();
case LONG:
return jp.getLongValue();
case BIG_INTEGER:
return jp.getBigIntegerValue();
default:
return null;
}
case VALUE_NUMBER_FLOAT:
switch (jp.getNumberType()) {
case FLOAT:
return jp.getFloatValue();
case DOUBLE:
return jp.getDoubleValue();
case BIG_DECIMAL:
return jp.getDecimalValue();
default:
return null;
}
default:
return null;
}
}
示例4: parseBool
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
/** Parsers a bool value out of the input. */
static boolean parseBool(JsonParser parser) throws IOException {
JsonToken token = parser.currentToken();
if (token.isBoolean()) {
return parser.getBooleanValue();
}
String json = parser.getText();
if (json.equals("true")) {
return true;
} else if (json.equals("false")) {
return false;
}
throw new InvalidProtocolBufferException("Invalid bool value: " + json);
}
示例5: deserialize
import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public AttributeValueDto deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
JsonToken currentToken = jp.getCurrentToken();
if (currentToken != null) {
switch (currentToken) {
case VALUE_NUMBER_INT:
case VALUE_NUMBER_FLOAT:
return new DoubleAttributeValueDto(jp.getDoubleValue());
case VALUE_STRING:
return new StringAttributeValueDto(jp.getText());
case VALUE_TRUE:
return new BooleanAttributeValueDto(jp.getBooleanValue());
case VALUE_FALSE:
return new BooleanAttributeValueDto(jp.getBooleanValue());
case START_ARRAY: {
ArrayAttributeValueDto arrayValue = null;
ObjectMapper mapper = new ObjectMapper();
ArrayNode arrayNode = mapper.readTree(jp);
Iterator<JsonNode> it = arrayNode.elements();
JsonNodeType arrayElemType = null;
while (it.hasNext()) {
JsonNode node = it.next();
if (arrayValue == null) {
// get the first element type
arrayElemType = node.getNodeType();
switch (arrayElemType) {
case STRING:
arrayValue = new ArrayOfStringsAttributeValueDto();
break;
case NUMBER:
arrayValue = new ArrayOfDoublesAttributeValueDto();
break;
default:
throw new UnsupportedOperationException(
"Unsupported array attribute items type.");
}
} else if (arrayElemType != node.getNodeType()) {
String errString = String.format(
"Array doesn't support different element types!Expected:{}, Found:{} ",
arrayElemType, node.getNodeType());
LOGGER.warn(errString);
throw new UnsupportedOperationException(errString);
}
switch (arrayElemType) {
case STRING:
((ArrayOfStringsAttributeValueDto) arrayValue).add(node.asText());
break;
case NUMBER:
((ArrayOfDoublesAttributeValueDto) arrayValue).add(node.asDouble());
break;
default:
break;
}
}
return arrayValue;
}
default:
break;
}
}
throw new UnsupportedOperationException("Not supported attribute value yet.");
}