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