Class DefaultComparator

java.lang.Object
org.skyscreamer.jsonassert.comparator.AbstractComparator
org.skyscreamer.jsonassert.comparator.DefaultComparator
All Implemented Interfaces:
JSONComparator
Direct Known Subclasses:
ArraySizeComparator, CustomComparator

public class DefaultComparator extends AbstractComparator
This class is the default json comparator implementation. Comparison is performed according to JSONCompareMode that is passed as constructor's argument.
  • Constructor Details

  • Method Details

    • compareJSON

      public void compareJSON(String prefix, org.json.JSONObject expected, org.json.JSONObject actual, JSONCompareResult result)
      Description copied from interface: JSONComparator
      Compares two JSONObjects on the provided path represented by prefix and updates the result of the comparison in the result JSONCompareResult object.
      Parameters:
      prefix - the path in the json where the comparison happens
      expected - the expected JSON object
      actual - the actual JSON object
      result - 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 two Objects on the provided path represented by prefix and updates the result of the comparison in the result JSONCompareResult object.
      Parameters:
      prefix - the path in the json where the comparison happens
      expectedValue - the expected value
      actualValue - the actual value
      result - 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 two JSONArrays on the provided path represented by prefix and updates the result of the comparison in the result JSONCompareResult object.
      Parameters:
      prefix - the path in the json where the comparison happens
      expected - the expected JSON array
      actual - the actual JSON array
      result - stores the actual state of the comparison result
    • areNumbers

      protected boolean areNumbers(Object expectedValue, Object actualValue)
    • areNotSameDoubles

      protected boolean areNotSameDoubles(Object expectedValue, Object actualValue)