kwid_compare_lists()

kwid_compare_lists()#

Compare two JSON lists of records, allowing for unordered comparison. The function checks if both lists contain the same elements, considering optional metadata and private key exclusions.

Prototype

BOOL kwid_compare_lists(
    hgobj gobj,
    json_t *list,          // NOT owned
    json_t *expected,      // NOT owned
    BOOL without_metadata,
    BOOL without_private,
    BOOL verbose
);

Parameters

Key

Type

Description

gobj

hgobj

Pointer to the GObj context for logging and error handling.

list

json_t *

The first JSON list to compare. Not owned by the function.

expected

json_t *

The second JSON list to compare against. Not owned by the function.

without_metadata

BOOL

If TRUE, metadata keys (keys starting with ‘__’) are ignored during comparison.

without_private

BOOL

If TRUE, private keys (keys starting with ‘_’) are ignored during comparison.

verbose

BOOL

If TRUE, detailed error messages are logged when mismatches occur.


Return Value

Returns TRUE if both lists contain the same elements, considering the specified exclusions. Returns FALSE if they differ.

Notes

This function performs a deep comparison of JSON lists, allowing for unordered elements. It internally calls kwid_compare_records() for record-level comparison.

Prototype

// Not applicable in JS

Prototype

# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples