本文整理匯總了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
}
}