kwid_compare_records()
#
Compares two JSON records deeply, allowing for unordered elements. The function checks for structural and value equivalence, optionally ignoring metadata and private fields.
Prototype
BOOL kwid_compare_records(
hgobj gobj,
json_t *record, // NOT owned
json_t *expected, // NOT owned
BOOL without_metadata,
BOOL without_private,
BOOL verbose
);
Parameters
Key |
Type |
Description |
---|---|---|
|
|
Handle to the GObj instance, used for logging errors. |
|
|
The JSON record to compare, not owned by the function. |
|
|
The expected JSON record to compare against, not owned by the function. |
|
|
If TRUE, metadata fields (keys starting with ‘__’) are ignored during comparison. |
|
|
If TRUE, private fields (keys starting with ‘_’) are ignored during comparison. |
|
|
If TRUE, logs detailed error messages when mismatches occur. |
Return Value
Returns TRUE if the records are identical, considering the specified filtering options. Returns FALSE if differences are found.
Notes
This function is useful for validating JSON records in databases or structured data comparisons. It internally calls kwid_compare_lists()
for array comparisons.
Prototype
// Not applicable in JS
Prototype
# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples