A JsonValueComparator uses the same type for the actual and expected parameters. This may be problematic when the actual type is not the same as the expected type.
Here's an example:
Actual is
Expected is
{
"date": "{#date_time_format:iso_instant#}"
}
A ClassCastException will be thrown because "date" will be "deserialized" as a null JSONObject, and DateTimeFormatComparator expects an actual of type String.
A
JsonValueComparatoruses the same type for theactualandexpectedparameters. This may be problematic when the actual type is not the same as the expected type.Here's an example:
Actual is
{ "date": null }Expected is
{ "date": "{#date_time_format:iso_instant#}" }A
ClassCastExceptionwill be thrown because"date"will be "deserialized" as a nullJSONObject, andDateTimeFormatComparatorexpects anactualof typeString.