JsonComparator (json_comparator v1.0.2)
View SourceProvides functionality for comparing JSON structures with configurable comparison options.
Summary
Functions
Compares two JSON structures for equality with configurable options.
Functions
Compares two JSON structures for equality with configurable options.
This function performs a deep comparison of two JSON structures, supporting various data types including maps, lists, DateTime objects, and structs. It provides configurable behavior for list comparison and DateTime precision.
Parameters
json1
- First JSON structure to comparejson2
- Second JSON structure to compareopts
- Optional keyword list of comparison options::strict_list_order
- Whentrue
, lists must have identical order to be considered equal. Defaults tofalse
:truncate_datetime_microseconds
- Whentrue
, DateTime comparisons ignore microseconds. Defaults totrue
:error_message
- Custom error message template to use when differences are found. The string%{path}
will be replaced with the path where the difference was found. Defaults to "Submitted JSONs do not match: %{path}"
Returns
:ok
- When the structures are equal according to the comparison rules{:error, message}
- When differences are found, where message is a string indicating the path where the first difference was encountered