diff options
author | Helmut Schaa <helmut.schaa@googlemail.com> | 2016-01-13 15:40:02 +0100 |
---|---|---|
committer | Helmut Schaa <helmut.schaa@googlemail.com> | 2016-01-13 15:56:38 +0100 |
commit | 00e475c43478f8fe8522218d8da8c58938a31450 (patch) | |
tree | 3345f5f93fed8811d837cf0c3d187552af4e5fcd /json_object.h | |
parent | 537f8bcbdbdc10ffa7673199a0be82ca4eb56ec8 (diff) | |
download | json-c-00e475c43478f8fe8522218d8da8c58938a31450.tar.gz |
Add utility function for comparing json_objects
Diffstat (limited to 'json_object.h')
-rw-r--r-- | json_object.h | 20 |
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 |