Class DefaultComparator
java.lang.Object
org.skyscreamer.jsonassert.comparator.AbstractComparator
org.skyscreamer.jsonassert.comparator.DefaultComparator
- All Implemented Interfaces:
JSONComparator
- Direct Known Subclasses:
ArraySizeComparator,CustomComparator
This class is the default json comparator implementation.
Comparison is performed according to
JSONCompareMode that is passed as constructor's argument.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanareNotSameDoubles(Object expectedValue, Object actualValue) protected booleanareNumbers(Object expectedValue, Object actualValue) voidcompareJSON(String prefix, org.json.JSONObject expected, org.json.JSONObject actual, JSONCompareResult result) Compares twoJSONObjects on the provided path represented byprefixand updates the result of the comparison in theresultJSONCompareResultobject.voidcompareJSONArray(String prefix, org.json.JSONArray expected, org.json.JSONArray actual, JSONCompareResult result) Compares twoJSONArrays on the provided path represented byprefixand updates the result of the comparison in theresultJSONCompareResultobject.voidcompareValues(String prefix, Object expectedValue, Object actualValue, JSONCompareResult result) Compares twoObjects on the provided path represented byprefixand updates the result of the comparison in theresultJSONCompareResultobject.Methods inherited from class org.skyscreamer.jsonassert.comparator.AbstractComparator
checkJsonObjectKeysActualInExpected, checkJsonObjectKeysExpectedInActual, compareJSON, compareJSON, compareJSONArrayOfJsonObjects, compareJSONArrayOfSimpleValues, compareJSONArrayWithStrictOrder, recursivelyCompareJSONArray
-
Constructor Details
-
DefaultComparator
-
-
Method Details
-
compareJSON
public void compareJSON(String prefix, org.json.JSONObject expected, org.json.JSONObject actual, JSONCompareResult result) Description copied from interface:JSONComparatorCompares twoJSONObjects on the provided path represented byprefixand updates the result of the comparison in theresultJSONCompareResultobject.- Parameters:
prefix- the path in the json where the comparison happensexpected- the expected JSON objectactual- the actual JSON objectresult- stores the actual state of the comparison result
-
compareValues
public void compareValues(String prefix, Object expectedValue, Object actualValue, JSONCompareResult result) Description copied from interface:JSONComparatorCompares twoObjects on the provided path represented byprefixand updates the result of the comparison in theresultJSONCompareResultobject.- Parameters:
prefix- the path in the json where the comparison happensexpectedValue- the expected valueactualValue- the actual valueresult- stores the actual state of the comparison result
-
compareJSONArray
public void compareJSONArray(String prefix, org.json.JSONArray expected, org.json.JSONArray actual, JSONCompareResult result) Description copied from interface:JSONComparatorCompares twoJSONArrays on the provided path represented byprefixand updates the result of the comparison in theresultJSONCompareResultobject.- Parameters:
prefix- the path in the json where the comparison happensexpected- the expected JSON arrayactual- the actual JSON arrayresult- stores the actual state of the comparison result
-
areNumbers
-
areNotSameDoubles
-