本文整理匯總了Java中com.fasterxml.jackson.databind.node.JsonNodeType.BOOLEAN屬性的典型用法代碼示例。如果您正苦於以下問題:Java JsonNodeType.BOOLEAN屬性的具體用法?Java JsonNodeType.BOOLEAN怎麽用?Java JsonNodeType.BOOLEAN使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類com.fasterxml.jackson.databind.node.JsonNodeType
的用法示例。
在下文中一共展示了JsonNodeType.BOOLEAN屬性的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: toRS
public static Object toRS(JsonNode value) {
if (value.getNodeType() == JsonNodeType.STRING) {
return value.asText();
} else if (value.getNodeType() == JsonNodeType.NUMBER) {
if (value.numberType() == JsonParser.NumberType.INT) {
return value.asInt();
} else if (value.numberType() == JsonParser.NumberType.LONG) {
return value.asLong();
} else if (value.numberType() == JsonParser.NumberType.DOUBLE) {
return value.asDouble();
}
} else if (value.getNodeType() == JsonNodeType.BOOLEAN) {
return value.asBoolean();
} else if ( value instanceof ArrayNode ) {
List<Object> array = new ArrayList<Object>();
value.elements().forEachRemaining( (e)->{
array.add( toRS( e ) );
});
return array;
} else if (value instanceof ObjectNode) {
return convert( (ObjectNode) value );
}
return null;
}
示例2: parseBooleanParamFromUserInfo
private Boolean parseBooleanParamFromUserInfo(JsonNode userInfo, String paramName) {
if (null == userInfo || null == paramName) {
return null;
}
if (userInfo.get(paramName).getNodeType() == JsonNodeType.BOOLEAN) {
Boolean value = userInfo.get(paramName).asBoolean() ? Boolean.TRUE : Boolean.FALSE;
return value;
}
return null;
}
示例3: createObjectModel
private void createObjectModel(JsonNode node, ModelBuilder modelBuilder, String apiName) {
Iterator<String> fieldNames = node.fieldNames();
while (fieldNames.hasNext()) {
String field = fieldNames.next();
JsonNode leafNode = node.get(field);
if (leafNode.getNodeType() == JsonNodeType.NUMBER) {
if (leafNode.isInt() || leafNode.isLong()) {
modelBuilder.withIntegerPropertyNamed(field).withExample(leafNode.asLong());
} else if (leafNode.isFloat() || leafNode.isDouble()) {
modelBuilder.withNumberPropertyNamed(field).withExample(leafNode.asDouble());
}
} else if (leafNode.getNodeType() == JsonNodeType.BOOLEAN) {
modelBuilder.withBooleanPropertyNamed(field).withExample(leafNode.asBoolean());
} else if (leafNode.getNodeType() == JsonNodeType.STRING) {
modelBuilder.withStringPropertyNamed(field).withExample(leafNode.asText());
} else if (leafNode.getNodeType() == JsonNodeType.OBJECT) {
String refName = apiName+"-"+field;
modelBuilder.withReferencePropertyNamed(field).withReferenceTo(refName);
ModelBuilder objModelBuilder = new ModelBuilder();
createObjectModel(leafNode, objModelBuilder, refName);
models.put(refName, objModelBuilder);
}else if(leafNode.getNodeType() == JsonNodeType.ARRAY){
createArrayModel(leafNode, modelBuilder.withArrayProperty(field), apiName+"-"+field);
}
}
}
示例4: deserialize
@Override
public CustomAttribute deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
CustomAttribute cda = null;
final String currentName = jp.getParsingContext().getCurrentName();
final ObjectMapper mapper = (ObjectMapper) jp.getCodec();
final ValueNode vNode = mapper.readTree(jp);
if (vNode.asToken().isScalarValue()) {
if (vNode.getNodeType() == JsonNodeType.BOOLEAN) {
cda = new CustomAttribute<Boolean>(currentName, vNode.asBoolean(), Boolean.class);
} else if (vNode.getNodeType() == JsonNodeType.STRING) {
cda = new CustomAttribute<String>(currentName, vNode.asText(), String.class);
} else if (vNode.getNodeType() == JsonNodeType.NUMBER) {
final NumericNode nNode = (NumericNode) vNode;
if (currentName.endsWith("_at")) {
cda = new CustomAttribute<Long>(currentName, vNode.longValue(), Long.class);
} else if (nNode.isInt()) {
cda = new CustomAttribute<Integer>(currentName, vNode.intValue(), Integer.class);
} else if (nNode.isFloat()) {
cda = new CustomAttribute<Float>(currentName, vNode.floatValue(), Float.class);
} else if (nNode.isDouble()) {
cda = new CustomAttribute<Double>(currentName, vNode.doubleValue(), Double.class);
} else if (nNode.isLong()) {
cda = new CustomAttribute<Long>(currentName, vNode.longValue(), Long.class);
} else {
cda = new CustomAttribute<String>(currentName, vNode.asText(), String.class);
}
} else {
cda = new CustomAttribute<String>(currentName, vNode.asText(), String.class);
}
}
return cda;
}
示例5: parseProperties
private void parseProperties(QueryPart queryPart, ObjectNode properties) throws QueryException {
Iterator<Entry<String, JsonNode>> fields = properties.fields();
while (fields.hasNext()) {
Entry<String, JsonNode> entry = fields.next();
String propertySetName = entry.getKey();
JsonNode value = entry.getValue();
if (value.isObject()) {
ObjectNode set = (ObjectNode)value;
Iterator<Entry<String, JsonNode>> propertySetFields = set.fields();
while (propertySetFields.hasNext()) {
Entry<String, JsonNode> propertyEntry = propertySetFields.next();
JsonNode propertyValue = propertyEntry.getValue();
if (propertyValue.isValueNode()) {
if (propertyValue.getNodeType() == JsonNodeType.BOOLEAN) {
queryPart.addProperty(propertySetName, propertyEntry.getKey(), propertyValue.asBoolean());
} else if (propertyValue.getNodeType() == JsonNodeType.NUMBER) {
queryPart.addProperty(propertySetName, propertyEntry.getKey(), propertyValue.asDouble());
} else if (propertyValue.getNodeType() == JsonNodeType.STRING) {
queryPart.addProperty(propertySetName, propertyEntry.getKey(), propertyValue.asText());
} else if (propertyValue.getNodeType() == JsonNodeType.NULL) {
queryPart.addProperty(propertySetName, propertyEntry.getKey(), null);
}
} else {
throw new QueryException("property \"" + propertyEntry.getKey() + "\" type not supported");
}
}
} else {
throw new QueryException("Query language has changed, propertyset name required now");
}
}
}
示例6: readOptBoolean
private boolean readOptBoolean(JsonNode rootNode, int position, boolean nodeNotPresentValue) throws MessageParseException
{
JsonNode booleanNode = rootNode.get(position);
if (null == booleanNode) {
return nodeNotPresentValue;
}
if (JsonNodeType.BOOLEAN != booleanNode.getNodeType()) {
throw new MessageParseException("Expected boolean type at position " + position);
}
return booleanNode.asBoolean();
}
示例7: IsJsonBoolean
private IsJsonBoolean(Matcher<? super Boolean> booleanMatcher) {
super(JsonNodeType.BOOLEAN);
this.booleanMatcher = Objects.requireNonNull(booleanMatcher);
}
示例8: isBoolean
public final boolean isBoolean()
{
return getNodeType() == JsonNodeType.BOOLEAN;
}
示例9: doDeserialize
@Override
public Button doDeserialize(ObjectCodec oc, JsonNode node, JsonParser jp, DeserializationContext ctxt) throws IOException {
Button btn = new Button();
// Set title
JsonNode title = node.get("title");
if(title == null) {
title = node.get("&title");
}
TranslationObject loc = null;
if(title != null) {
loc = oc.treeToValue(title, TranslationObject.class);
}
btn.setTitle(loc);
// Set referenceIsHandledByUser
JsonNode isHandledByUser = node.get("isHandledByUser");
if(isHandledByUser != null && isHandledByUser.getNodeType() == JsonNodeType.STRING) {
btn.setIsHandledByUser(isHandledByUser.textValue());
}
// Set isHandler
JsonNode handler = node.get("isHandler");
if(handler != null && handler.getNodeType() == JsonNodeType.BOOLEAN) {
btn.setIsHandler(handler.booleanValue());
}
// Set hasHandler
handler = node.get("hasHandler");
if(handler != null && handler.getNodeType() == JsonNodeType.BOOLEAN) {
btn.setHasHandler(handler.booleanValue());
}
// Set user groups
JsonNode groups = node.get("permissions");
if(groups != null && groups.getNodeType() == JsonNodeType.ARRAY) {
for(JsonNode group : groups) {
if(group.getNodeType() == JsonNodeType.STRING) {
btn.getPermissions().add(group.textValue());
}
}
}
// Set type
JsonNode type = node.get("type");
if(type != null && type.getNodeType() == JsonNodeType.STRING) {
btn.setType(ButtonType.valueOf(type.textValue()));
}
// Set states
JsonNode states = node.get("states");
if(states != null && states.getNodeType() == JsonNodeType.ARRAY) {
for(JsonNode state : states) {
if(state.getNodeType() == JsonNodeType.STRING) {
btn.getStates().add(VisibilityState.valueOf(state.textValue()));
}
}
}
JsonNode customHandler = node.get("customHandler");
if(customHandler != null && customHandler.getNodeType() == JsonNodeType.STRING) {
btn.setCustomHandler(customHandler.textValue());
}
return btn;
}