From 6e57173fab673b66870b3e181f09542da0d61587 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 6 Nov 2009 12:24:44 -0800 Subject: [PATCH] json: Make json_equal() compare objects correctly. The previous code checked only that JSON objects have members with the same names. This commit makes json_equal() also check that like-named members have the same values. --- lib/json.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/json.c b/lib/json.c index dfd6b8453..cdcfba598 100644 --- a/lib/json.c +++ b/lib/json.c @@ -500,14 +500,15 @@ json_hash(const struct json *json, size_t basis) static bool json_equal_object(const struct shash *a, const struct shash *b) { - struct shash_node *node; + struct shash_node *a_node; if (shash_count(a) != shash_count(b)) { return false; } - SHASH_FOR_EACH (node, a) { - if (!shash_find(b, node->name)) { + SHASH_FOR_EACH (a_node, a) { + struct shash_node *b_node = shash_find(b, a_node->name); + if (!b_node || !json_equal(a_node->data, b_node->data)) { return false; } } -- 2.45.2