Add utility function for comparing json_objects

This commit is contained in:
Helmut Schaa
2016-01-13 15:40:02 +01:00
parent 537f8bcbdb
commit 00e475c434
2 changed files with 101 additions and 0 deletions

View File

@@ -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