本文整理汇总了Java中com.fasterxml.jackson.databind.node.JsonNodeType.NULL属性的典型用法代码示例。如果您正苦于以下问题:Java JsonNodeType.NULL属性的具体用法?Java JsonNodeType.NULL怎么用?Java JsonNodeType.NULL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.fasterxml.jackson.databind.node.JsonNodeType
的用法示例。
在下文中一共展示了JsonNodeType.NULL属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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");
}
}
}
示例2: doDeserialize
@Override
protected Option doDeserialize(ObjectCodec oc, JsonNode node, JsonParser jp, DeserializationContext ctxt) throws IOException {
JsonNode value = node.get("value");
if(value == null || value.getNodeType() == JsonNodeType.NULL) {
return null;
}
Option o = new Option(value.textValue());
// Set deprecated
JsonNode dep = node.get("deprecated");
if(dep != null && dep.getNodeType() != JsonNodeType.NULL) {
o.setDeprecated(dep.asBoolean());
}
// 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);
}
o.setTitle(loc);
return o;
}
示例3: deserialize
@Override
public final T deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
ObjectCodec oc = jp.getCodec();
JsonNode node = oc.readTree(jp);
if(node == null || node.getNodeType() == JsonNodeType.NULL) {
return null;
}
return doDeserialize(oc, node, jp, ctxt);
}
示例4: IsJsonNull
private IsJsonNull() {
super(JsonNodeType.NULL);
}
示例5: isNull
public final boolean isNull()
{
return getNodeType() == JsonNodeType.NULL;
}
示例6: isValueMissing
public static boolean isValueMissing(JsonNodeWrapper node) {
return node == null || node.getNode().getNodeType() == JsonNodeType.MISSING || node.getNode().getNodeType() == JsonNodeType.NULL;
}
示例7: getOption
/**
* Returns ReferenceOption from given JsonObject
* @param root JsonNode containing actual value node as one of its nodes and functioning as a root for titlePath
* @param reference Reference that is used to extract value and title from given JsonNode
* @return Single ReferenceOption containing value and title as per specification
*/
ReferenceOption getOption(JsonNode root, Reference reference, Language language) {
if(root == null || root.getNodeType() != JsonNodeType.OBJECT) {
// Needs an Object as its root
return null;
}
String[] path = reference.getValuePathParts();
String valueKey = path[path.length-1];
path = reference.getTitlePathParts();
JsonNode value = root.get(valueKey);
String valueStr = (value != null) ? value.asText() : null;
String titleStr = null;
if(valueStr == null) {
// Don't return option since we don't have a value
return null;
}
if(path != null) {
JsonPathParser titleParser = new JsonPathParser(root, path);
// This should return either a string node or an object that represents a translation object
// We try to detect translation object by checking if the object contains parameter 'default' that has content
JsonNode title = titleParser.findFirstTerminatingValue();
if(title != null) {
if (title.getNodeType() == JsonNodeType.OBJECT) {
JsonNode def = title.get("default");
// If this node is a translation object then it has to contain non null default parameter.
if (def != null && def.getNodeType() != JsonNodeType.NULL) {
JsonNode langField = title.get(language.toValue());
if (langField != null && langField.getNodeType() != JsonNodeType.NULL) {
titleStr = langField.textValue();
} else {
titleStr = def.textValue();
}
}
} else {
// If we have some text in title parameter then put it inside the default in translation object
if (StringUtils.hasText(title.textValue())) {
titleStr = title.textValue();
}
}
}
} else {
titleStr = valueStr;
}
ReferenceOption option = new ReferenceOption(valueStr, new ReferenceOptionTitle(ReferenceTitleType.LITERAL, titleStr));
return option;
}