本文整理了Java中com.fasterxml.jackson.databind.JsonNode.isNull()
方法的一些代码示例,展示了JsonNode.isNull()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.isNull()
方法的具体详情如下:
包路径:com.fasterxml.jackson.databind.JsonNode
类名称:JsonNode
方法名:isNull
[英]Method that can be used to check if this node was created from JSON literal null value.
[中]方法,该方法可用于检查此节点是否是从JSON文本空值创建的。
代码示例来源:origin: redisson/redisson
/**
* Method that is similar to {@link #has(String)}, but that will
* return <code>false</code> for explicitly added nulls.
*<p>
* This method is functionally equivalent to:
*<pre>
* node.get(fieldName) != null && !node.get(fieldName).isNull()
*</pre>
*
* @since 2.1
*/
public boolean hasNonNull(String fieldName) {
JsonNode n = get(fieldName);
return (n != null) && !n.isNull();
}
代码示例来源:origin: Activiti/Activiti
public static String getValueAsString(String name, JsonNode objectNode) {
String propertyValue = null;
JsonNode propertyNode = objectNode.get(name);
if (propertyNode != null && !propertyNode.isNull()) {
propertyValue = propertyNode.asText();
}
return propertyValue;
}
代码示例来源:origin: Activiti/Activiti
protected static String getActiveValue(String originalValue, String propertyName, ObjectNode elementProperties) {
String activeValue = originalValue;
if (elementProperties != null) {
JsonNode overrideValueNode = elementProperties.get(propertyName);
if (overrideValueNode != null) {
if (overrideValueNode.isNull()) {
activeValue = null;
} else {
activeValue = overrideValueNode.asText();
}
}
}
return activeValue;
}
代码示例来源:origin: Activiti/Activiti
protected String getValueAsString(String name,
JsonNode objectNode) {
String propertyValue = null;
JsonNode propertyNode = objectNode.get(name);
if (propertyNode != null && !propertyNode.isNull()) {
propertyValue = propertyNode.asText();
}
return propertyValue;
}
代码示例来源:origin: Activiti/Activiti
protected String getActiveValue(String originalValue, String propertyName, ObjectNode taskElementProperties) {
String activeValue = originalValue;
if (taskElementProperties != null) {
JsonNode overrideValueNode = taskElementProperties.get(propertyName);
if (overrideValueNode != null) {
if (overrideValueNode.isNull()) {
activeValue = null;
} else {
activeValue = overrideValueNode.asText();
}
}
}
return activeValue;
}
代码示例来源:origin: redisson/redisson
/**
* Method that is similar to {@link #has(int)}, but that will
* return <code>false</code> for explicitly added nulls.
*<p>
* This method is equivalent to:
*<pre>
* node.get(index) != null && !node.get(index).isNull()
*</pre>
*
* @since 2.1
*/
public boolean hasNonNull(int index) {
JsonNode n = get(index);
return (n != null) && !n.isNull();
}
代码示例来源:origin: Activiti/Activiti
protected List<String> getValueAsList(String name,
JsonNode objectNode) {
List<String> resultList = new ArrayList<String>();
JsonNode valuesNode = objectNode.get(name);
if (valuesNode != null) {
for (JsonNode valueNode : valuesNode) {
if (valueNode.get("value") != null && !valueNode.get("value").isNull()) {
resultList.add(valueNode.get("value").asText());
}
}
}
return resultList;
}
代码示例来源:origin: auth0/java-jwt
String getString(Map<String, JsonNode> tree, String claimName) {
JsonNode node = tree.get(claimName);
if (node == null || node.isNull()) {
return null;
}
return node.asText(null);
}
}
代码示例来源:origin: Activiti/Activiti
protected boolean getValueAsBoolean(String name,
JsonNode objectNode) {
boolean propertyValue = false;
JsonNode propertyNode = objectNode.get(name);
if (propertyNode != null && !propertyNode.isNull()) {
propertyValue = propertyNode.asBoolean();
}
return propertyValue;
}
代码示例来源:origin: Activiti/Activiti
protected void setOutcomeConditionExpression(SequenceFlow flow, JsonNode expressionNode) {
Long formId = null;
if (expressionNode.get("outcomeFormId") != null && !(expressionNode.get("outcomeFormId").isNull())) {
formId = expressionNode.get("outcomeFormId").asLong();
}
String operator = null;
if (expressionNode.get("operator") != null && expressionNode.get("operator").isNull() == false) {
operator = expressionNode.get("operator").asText();
}
String outcomeName = null;
if (expressionNode.get("outcomeName") != null && !(expressionNode.get("outcomeName").isNull())) {
outcomeName = expressionNode.get("outcomeName").asText();
}
if (formId != null && operator != null && outcomeName != null) {
flow.setConditionExpression("${form" + formId + "outcome " + operator + " " + outcomeName + "}");
addExtensionElement("conditionFormId", String.valueOf(formId), flow);
addExtensionElement("conditionOperator", operator, flow);
addExtensionElement("conditionOutcomeName", outcomeName, flow);
}
}
代码示例来源:origin: auth0/java-jwt
String getString(Map<String, JsonNode> tree, String claimName) {
JsonNode node = tree.get(claimName);
if (node == null || node.isNull()) {
return null;
}
return node.asText(null);
}
}
代码示例来源:origin: Activiti/Activiti
protected boolean doesElementPropertyExist(String id, String propertyName, ObjectNode infoNode) {
boolean exists = false;
if (infoNode.get(BPMN_NODE) != null && infoNode.get(BPMN_NODE).get(id) != null && infoNode.get(BPMN_NODE).get(id).get(propertyName) != null) {
JsonNode propNode = infoNode.get(BPMN_NODE).get(id).get(propertyName);
if (!propNode.isNull()) {
exists = true;
}
}
return exists;
}
代码示例来源:origin: Activiti/Activiti
protected void setFieldConditionExpression(SequenceFlow flow, JsonNode expressionNode) {
String fieldId = null;
if (expressionNode.get("fieldId") != null && !(expressionNode.get("fieldId").isNull())) {
fieldId = expressionNode.get("fieldId").asText();
}
String operator = null;
if (expressionNode.get("operator") != null && !(expressionNode.get("operator").isNull())) {
operator = expressionNode.get("operator").asText();
}
String value = null;
if (expressionNode.get("value") != null && !(expressionNode.get("value").isNull())) {
value = expressionNode.get("value").asText();
}
if (fieldId != null && operator != null && value != null) {
flow.setConditionExpression("${" + fieldId + " " + operator + " " + value + "}");
addExtensionElement("conditionFieldId", fieldId, flow);
addExtensionElement("conditionOperator", operator, flow);
addExtensionElement("conditionValue", value, flow);
}
}
代码示例来源:origin: Activiti/Activiti
public static String getPropertyValueAsString(String name, JsonNode objectNode) {
String propertyValue = null;
JsonNode propertyNode = getProperty(name, objectNode);
if (propertyNode != null && propertyNode.isNull() == false) {
propertyValue = propertyNode.asText();
}
return propertyValue;
}
代码示例来源:origin: apache/avro
return defaultValue.isBoolean();
case NULL:
return defaultValue.isNull();
case ARRAY:
if (!defaultValue.isArray())
if (!isValidDefault(field.schema(),
defaultValue.has(field.name())
? defaultValue.get(field.name())
: field.defaultValue()))
return false;
代码示例来源:origin: auth0/java-jwt
List<String> getStringOrArray(Map<String, JsonNode> tree, String claimName) throws JWTDecodeException {
JsonNode node = tree.get(claimName);
if (node == null || node.isNull() || !(node.isArray() || node.isTextual())) {
return null;
}
if (node.isTextual() && !node.asText().isEmpty()) {
return Collections.singletonList(node.asText());
}
List<String> list = new ArrayList<>(node.size());
for (int i = 0; i < node.size(); i++) {
try {
list.add(objectReader.treeToValue(node.get(i), String.class));
} catch (JsonProcessingException e) {
throw new JWTDecodeException("Couldn't map the Claim's array contents to String", e);
}
}
return list;
}
代码示例来源:origin: Activiti/Activiti
protected void addExtensionElement(String name, JsonNode elementNode, UserTask task) {
if (elementNode != null && !elementNode.isNull() && StringUtils.isNotEmpty(elementNode.asText())) {
addExtensionElement(name, elementNode.asText(), task);
}
}
代码示例来源:origin: apache/incubator-pinot
public static Object extractValue(@Nullable JsonNode jsonValue, FieldSpec fieldSpec) {
if (fieldSpec.isSingleValueField()) {
if (jsonValue != null && !jsonValue.isNull()) {
return extractSingleValue(jsonValue, fieldSpec.getDataType());
} else {
return fieldSpec.getDefaultNullValue();
}
} else {
if (jsonValue != null && !jsonValue.isNull()) {
if (jsonValue.isArray()) {
int numValues = jsonValue.size();
if (numValues != 0) {
Object[] values = new Object[numValues];
for (int i = 0; i < numValues; i++) {
values[i] = extractSingleValue(jsonValue.get(i), fieldSpec.getDataType());
}
return values;
} else {
return new Object[]{fieldSpec.getDefaultNullValue()};
}
} else {
return new Object[]{extractSingleValue(jsonValue, fieldSpec.getDataType())};
}
} else {
return new Object[]{fieldSpec.getDefaultNullValue()};
}
}
}
代码示例来源:origin: Activiti/Activiti
Map<String, JsonNode> sourceRefMap) {
if (objectNode.get(EDITOR_CHILD_SHAPES) != null) {
for (JsonNode jsonChildNode : objectNode.get(EDITOR_CHILD_SHAPES)) {
if (targetNode != null && !targetNode.isNull()) {
String targetRefId = targetNode.get(EDITOR_SHAPE_ID).asText();
List<JsonNode> sourceAndTargetList = new ArrayList<JsonNode>();
sourceAndTargetList.add(sourceRefMap.get(childNode.get(EDITOR_SHAPE_ID).asText()));
sourceAndTargetList.add(shapeMap.get(targetRefId));
sourceAndTargetMap.put(childEdgeId,
代码示例来源:origin: Activiti/Activiti
public static JsonNode validateIfNodeIsTextual(JsonNode node) {
if (node != null && !node.isNull() && node.isTextual() && StringUtils.isNotEmpty(node.asText())) {
try {
node = validateIfNodeIsTextual(objectMapper.readTree(node.asText()));
} catch(Exception e) {
logger.error("Error converting textual node", e);
}
}
return node;
}
内容来源于网络,如有侵权,请联系作者删除!