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
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
areNotSameDoubles
(Object expectedValue, Object actualValue) protected boolean
areNumbers
(Object expectedValue, Object actualValue) void
compareJSON
(String prefix, org.json.JSONObject expected, org.json.JSONObject actual, JSONCompareResult result) Compares twoJSONObject
s on the provided path represented byprefix
and updates the result of the comparison in theresult
JSONCompareResult
object.void
compareJSONArray
(String prefix, org.json.JSONArray expected, org.json.JSONArray actual, JSONCompareResult result) Compares twoJSONArray
s on the provided path represented byprefix
and updates the result of the comparison in theresult
JSONCompareResult
object.void
compareValues
(String prefix, Object expectedValue, Object actualValue, JSONCompareResult result) Compares twoObject
s on the provided path represented byprefix
and updates the result of the comparison in theresult
JSONCompareResult
object.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:JSONComparator
Compares twoJSONObject
s on the provided path represented byprefix
and updates the result of the comparison in theresult
JSONCompareResult
object.- 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:JSONComparator
Compares twoObject
s on the provided path represented byprefix
and updates the result of the comparison in theresult
JSONCompareResult
object.- 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:JSONComparator
Compares twoJSONArray
s on the provided path represented byprefix
and updates the result of the comparison in theresult
JSONCompareResult
object.- 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
-