當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonNode.equals方法代碼示例

本文整理匯總了Java中com.fasterxml.jackson.databind.JsonNode.equals方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonNode.equals方法的具體用法?Java JsonNode.equals怎麽用?Java JsonNode.equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.fasterxml.jackson.databind.JsonNode的用法示例。


在下文中一共展示了JsonNode.equals方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: pathAny

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
/**
 * PathAny matcher that checks if any element of the final
 * result matches the expected result.
 *
 * @param expectedResult Expected result given by the waiter definition
 * @param finalResult    Final result of the resource got by the execution
 *                       of the JmesPath expression given by the waiter
 *                       definition
 * @return True if any single element of the final result matches
 *         the expected result, False if none matched
 */
public static boolean pathAny(JsonNode expectedResult, JsonNode finalResult) {
    if (finalResult.isNull()) {
        return false;
    }
    if (!finalResult.isArray()) {
        throw new RuntimeException("Expected an array");
    }
    for (JsonNode element : finalResult) {
        if (element.equals(expectedResult)) {
            return true;
        }
    }
    return false;

}
 
開發者ID:aws,項目名稱:aws-sdk-java-v2,代碼行數:27,代碼來源:AcceptorPathMatcher.java

示例2: pathAny

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
/**
 * PathAny matcher that checks if any element of the final
 * result matches the expected result
 *
 * @param expectedResult Expected result given by the waiter definition
 * @param finalResult    Final result of the resource got by the execution
 *                       of the JmesPath expression given by the waiter
 *                       definition
 * @return True if any single element of the final result matches
 * the expected result, False if none matched
 */
public static boolean pathAny(JsonNode expectedResult, JsonNode finalResult) {
    if (finalResult.isNull()) {
        return false;
    }
    if (!finalResult.isArray()) {
        throw new RuntimeException("Expected an array");
    }
    for (JsonNode element : finalResult) {
        if (element.equals(expectedResult)) {
            return true;
        }
    }
    return false;

}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:27,代碼來源:AcceptorPathMatcher.java

示例3: compareJson

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
public static void compareJson(String expected, String actual) throws IOException {
  if(ElasticsearchCluster.USE_EXTERNAL_ES5){
    // ignore json comparison for now
    return;
  }

  ObjectMapper m = new ObjectMapper();
  JsonNode expectedRootNode = m.readTree(expected);
  JsonNode actualRootNode = m.readTree(actual);
  if (!expectedRootNode.equals(actualRootNode)) {
    ObjectWriter writer = m.writerWithDefaultPrettyPrinter();
    String message = String.format("Comparison between JSON values failed.\nExpected:\n%s\nActual:\n%s", expected, actual);
    // assertEquals gives a better diff
    assertEquals(message, writer.writeValueAsString(expectedRootNode), writer.writeValueAsString(actualRootNode));
    throw new RuntimeException(message);
  }
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:18,代碼來源:ElasticBaseTestQuery.java

示例4: compare

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
@Override
public int compare(JsonNode o1, JsonNode o2) {
    if (o1.equals(o2)) {
        return 0;
    }
    if ((o1 instanceof NumericNode) && (o2 instanceof NumericNode)) {
        double d1 = ((NumericNode) o1).asDouble();
        double d2 = ((NumericNode) o2).asDouble();
        return Double.compare(d1, d2);
    }
    int comp = o1.asText().compareTo(o2.asText());
    if (comp == 0) {
        return Integer.compare(o1.hashCode(), o2.hashCode());
    }
    return comp;
}
 
開發者ID:pegasystems,項目名稱:api2swagger,代碼行數:17,代碼來源:SerializationMatchers.java

示例5: doEquivalent

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
@Override
protected boolean doEquivalent(final JsonNode a, final JsonNode b) {
    /*
     * If both are numbers, delegate to the helper method
     */
    if (a.isNumber() && b.isNumber()) {
        return numEquals(a, b);
    }

    final JsonNodeType typeA = a.getNodeType();
    final JsonNodeType typeB = b.getNodeType();

    /*
     * If they are of different types, no dice
     */
    if (typeA != typeB) {
        return false;
    }

    /*
     * For all other primitive types than numbers, trust JsonNode
     */
    if (!a.isContainerNode()) {
        return a.equals(b);
    }

    /*
     * OK, so they are containers (either both arrays or objects due to the
     * test on types above). They are obviously not equal if they do not
     * have the same number of elements/members.
     */
    if (a.size() != b.size()) {
        return false;
    }

    /*
     * Delegate to the appropriate method according to their type.
     */
    return typeA == JsonNodeType.ARRAY ? arrayEquals(a, b) : objectEquals(a, b);
}
 
開發者ID:line,項目名稱:centraldogma,代碼行數:41,代碼來源:JsonNumEquals.java

示例6: numEquals

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
private static boolean numEquals(final JsonNode a, final JsonNode b) {
    /*
     * If both numbers are integers, delegate to JsonNode.
     */
    if (a.isIntegralNumber() && b.isIntegralNumber()) {
        return a.equals(b);
    }

    /*
     * Otherwise, compare decimal values.
     */
    return a.decimalValue().compareTo(b.decimalValue()) == 0;
}
 
開發者ID:line,項目名稱:centraldogma,代碼行數:14,代碼來源:JsonNumEquals.java

示例7: pathAll

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
/**
 * PathAll matcher that checks if each element of the final
 * result matches the expected result.
 *
 * @param expectedResult Expected result given by the waiter definition
 * @param finalResult    Final result of the resource got by the execution
 *                       of the JmesPath expression given by the waiter
 *                       definition
 * @return True if all elements of the final result matches
 *         the expected result, False otherwise
 */
public static boolean pathAll(JsonNode expectedResult, JsonNode finalResult) {
    if (finalResult.isNull()) {
        return false;
    }
    if (!finalResult.isArray()) {
        throw new RuntimeException("Expected an array");
    }
    for (JsonNode element : finalResult) {
        if (!element.equals(expectedResult)) {
            return false;
        }
    }
    return true;
}
 
開發者ID:aws,項目名稱:aws-sdk-java-v2,代碼行數:26,代碼來源:AcceptorPathMatcher.java

示例8: sameJson

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
private boolean sameJson(String s1, String s2) {
    try {
        JsonNode tree1 = MAPPER.readTree(s1);
        JsonNode tree2 = MAPPER.readTree(s2);
        return tree1.equals(tree2);
    } catch (IOException e) {
        System.out.println("Exception: " + e);
    }
    return false;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:11,代碼來源:CoreModelCacheTest.java

示例9: pathAll

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
/**
 * PathAll matcher that checks if each element of the final
 * result matches the expected result
 *
 * @param expectedResult Expected result given by the waiter definition
 * @param finalResult    Final result of the resource got by the execution
 *                       of the JmesPath expression given by the waiter
 *                       definition
 * @return True if all elements of the final result matches
 * the expected result, False otherwise
 */
public static boolean pathAll(JsonNode expectedResult, JsonNode finalResult) {
    if (finalResult.isNull()) {
        return false;
    }
    if (!finalResult.isArray()) {
        throw new RuntimeException("Expected an array");
    }
    for (JsonNode element : finalResult) {
        if (!element.equals(expectedResult)) {
            return false;
        }
    }
    return true;
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:26,代碼來源:AcceptorPathMatcher.java

示例10: path

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
/**
 * Path matcher that checks if the final result
 * matches the expected result.
 *
 * @param expectedResult Expected result given by the waiter definition
 * @param finalResult    Final result of the resource got by the execution
 *                       of the JmesPath expression given by the waiter
 *                       definition
 * @return True if the final result matches the expected result,
 *         False otherwise
 */
public static boolean path(JsonNode expectedResult, JsonNode finalResult) {
    return finalResult.equals(expectedResult);
}
 
開發者ID:aws,項目名稱:aws-sdk-java-v2,代碼行數:15,代碼來源:AcceptorPathMatcher.java

示例11: path

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
/**
 * Path matcher that checks if the final result
 * matches the expected result
 *
 * @param expectedResult Expected result given by the waiter definition
 * @param finalResult    Final result of the resource got by the execution
 *                       of the JmesPath expression given by the waiter
 *                       definition
 * @return True if the final result matches the expected result,
 * False otherwise
 */
public static boolean path(JsonNode expectedResult, JsonNode finalResult) {
    return finalResult.equals(expectedResult);
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:15,代碼來源:AcceptorPathMatcher.java


注:本文中的com.fasterxml.jackson.databind.JsonNode.equals方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。