ekino / jcv

JSON Content Validator (JCV) allows you to compare JSON contents with embedded validation.
https://ekino.github.io/jcv
MIT License
21 stars 0 forks source link

Strict typing in comparators may produce a ClassCastException #26

Open celcius112 opened 2 years ago

celcius112 commented 2 years ago

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

{
 "date": null
}

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.