From b674519695997ec55917ad8ed969ce26c606f44d Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Sun, 30 Apr 2017 20:04:44 +0200 Subject: [PATCH] Add cJSONUtils_GenerateMergePatchCaseSensitive --- cJSON_Utils.c | 13 +++++++++++-- cJSON_Utils.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cJSON_Utils.c b/cJSON_Utils.c index 2ff4c9d..3552af7 100644 --- a/cJSON_Utils.c +++ b/cJSON_Utils.c @@ -1247,9 +1247,8 @@ CJSON_PUBLIC(cJSON *) cJSONUtils_MergePatch(cJSON *target, const cJSON * const p return target; } -CJSON_PUBLIC(cJSON *) cJSONUtils_GenerateMergePatch(cJSON * const from, cJSON * const to) +static cJSON *generate_merge_patch(cJSON * const from, cJSON * const to, const cJSON_bool case_sensitive) { - cJSON_bool case_sensitive = false; cJSON *from_child = NULL; cJSON *to_child = NULL; cJSON *patch = NULL; @@ -1325,3 +1324,13 @@ CJSON_PUBLIC(cJSON *) cJSONUtils_GenerateMergePatch(cJSON * const from, cJSON * return patch; } + +CJSON_PUBLIC(cJSON *) cJSONUtils_GenerateMergePatch(cJSON * const from, cJSON * const to) +{ + return generate_merge_patch(from, to, false); +} + +CJSON_PUBLIC(cJSON *) cJSONUtils_GenerateMergePatchCaseSensitive(cJSON * const from, cJSON * const to) +{ + return generate_merge_patch(from, to, true); +} diff --git a/cJSON_Utils.h b/cJSON_Utils.h index 7cd06af..d826818 100644 --- a/cJSON_Utils.h +++ b/cJSON_Utils.h @@ -63,6 +63,7 @@ CJSON_PUBLIC(cJSON *) cJSONUtils_MergePatch(cJSON *target, const cJSON * const p /* generates a patch to move from -> to */ /* NOTE: This modifies objects in 'from' and 'to' by sorting the elements by their key */ CJSON_PUBLIC(cJSON *) cJSONUtils_GenerateMergePatch(cJSON * const from, cJSON * const to); +CJSON_PUBLIC(cJSON *) cJSONUtils_GenerateMergePatchCaseSensitive(cJSON * const from, cJSON * const to); /* Given a root object and a target object, construct a pointer from one to the other. */ CJSON_PUBLIC(char *) cJSONUtils_FindPointerFromObjectTo(const cJSON * const object, const cJSON * const target); -- GitLab