summaryrefslogtreecommitdiff
path: root/json_object.h
diff options
context:
space:
mode:
authorHelmut Schaa <helmut.schaa@googlemail.com>2016-01-13 15:40:02 +0100
committerHelmut Schaa <helmut.schaa@googlemail.com>2016-01-13 15:56:38 +0100
commit00e475c43478f8fe8522218d8da8c58938a31450 (patch)
tree3345f5f93fed8811d837cf0c3d187552af4e5fcd /json_object.h
parent537f8bcbdbdc10ffa7673199a0be82ca4eb56ec8 (diff)
downloadjson-c-00e475c43478f8fe8522218d8da8c58938a31450.tar.gz
Add utility function for comparing json_objects
Diffstat (limited to 'json_object.h')
-rw-r--r--json_object.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/json_object.h b/json_object.h
index 99b8edf..ee53524 100644
--- a/json_object.h
+++ b/json_object.h
@@ -691,6 +691,26 @@ extern const char* json_object_get_string(struct json_object *obj);
*/
extern int json_object_get_string_len(const struct json_object *obj);
+/** Check if two json_object's are equal
+ *
+ * If the passed objects are equal 1 will be returned.
+ * Equality is defined as follows:
+ * - json_objects of different types are never equal
+ * - json_objects of the same primitive type are equal if the
+ * c-representation of their value is equal
+ * - json-arrays are considered equal if all values at the same
+ * indices are equal (same order)
+ * - Complex json_objects are considered equal if all
+ * contained objects referenced by their key are equal,
+ * regardless their order.
+ *
+ * @param obj1 the first json_object instance
+ * @param obj2 the second json_object instance
+ * @returns whether both objects are equal or not
+ */
+extern int json_object_equal(struct json_object *obj1,
+ struct json_object *obj2);
+
#ifdef __cplusplus
}
#endif