本文整理汇总了Java中com.fasterxml.jackson.databind.JsonNode.getClass方法的典型用法代码示例。如果您正苦于以下问题:Java JsonNode.getClass方法的具体用法?Java JsonNode.getClass怎么用?Java JsonNode.getClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.databind.JsonNode
的用法示例。
在下文中一共展示了JsonNode.getClass方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isJsonNodeSubset
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
* Returns true if expected is a subset of returned
*
* This is used for JSON serialiser comparisons. This is taken from
* the 'equals' definition of JsonNode's, but without the length check
* on the list of children nodes, plus location reporting.
*
* @param expected
* @param returned
* @return
*/
protected boolean isJsonNodeSubset(JsonNode expected, JsonNode returned) {
if (returned == null) {
errorDescription = "Returned value is null, expected JSON:\n" + expected.toString();
return false;
}
if (returned == expected) return true;
if (returned.getClass() != expected.getClass()) {
errorDescription = "Returned value class is incorrect, expected JSON: " + expected.toString()
+ ", returned JSON: " + returned.toString();
return false;
}
switch (expected.getNodeType()) {
case ARRAY: return isArrayNodeSubset((ArrayNode)expected, (ArrayNode)returned);
case OBJECT: return isObjectNodeSubset((ObjectNode)expected, (ObjectNode)returned);
default: return isValueEqual((ValueNode)expected, (ValueNode)returned); // Will be a ValueNode subclass
}
}