当前位置: 首页>>代码示例>>Java>>正文


Java JsonNodeType.BOOLEAN属性代码示例

本文整理汇总了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;
}
 
开发者ID:liveoak-io,项目名称:liveoak,代码行数:24,代码来源:ConversionUtils.java

示例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;
}
 
开发者ID:Nexmo,项目名称:comms-router,代码行数:13,代码来源:IvrStrategyWithSimpleFlow.java

示例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);				
		}
	}		
}
 
开发者ID:pegasystems,项目名称:api2swagger,代码行数:28,代码来源:SwaggerModelGenerator.java

示例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;
}
 
开发者ID:intercom,项目名称:intercom-java,代码行数:32,代码来源:CustomAttributeDeserializer.java

示例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");
		}
	}
}
 
开发者ID:opensourceBIM,项目名称:BIMserver,代码行数:32,代码来源:JsonQueryObjectModelConverter.java

示例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();
}
 
开发者ID:fritz-gerneth,项目名称:java-wamp-server,代码行数:13,代码来源:PublishMessageConverter.java

示例7: IsJsonBoolean

private IsJsonBoolean(Matcher<? super Boolean> booleanMatcher) {
  super(JsonNodeType.BOOLEAN);
  this.booleanMatcher = Objects.requireNonNull(booleanMatcher);
}
 
开发者ID:spotify,项目名称:java-hamcrest,代码行数:4,代码来源:IsJsonBoolean.java

示例8: isBoolean

public final boolean isBoolean()
{
  return getNodeType() == JsonNodeType.BOOLEAN;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:4,代码来源:JsonNode.java

示例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;
}
 
开发者ID:Tietoarkisto,项目名称:metka,代码行数:67,代码来源:ButtonDeserializer.java


注:本文中的com.fasterxml.jackson.databind.node.JsonNodeType.BOOLEAN属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。