diff --git a/cJSON_Utils.c b/cJSON_Utils.c index 4f3a9ed8d..435c7e0e0 100644 --- a/cJSON_Utils.c +++ b/cJSON_Utils.c @@ -463,7 +463,14 @@ static cJSON *detach_path(cJSON *object, const unsigned char *path, const cJSON_ } else if (cJSON_IsObject(parent)) { - detached_item = cJSON_DetachItemFromObject(parent, (char*)child_pointer); + if (case_sensitive) + { + detached_item = cJSON_DetachItemFromObjectCaseSensitive(parent, (char*)child_pointer); + } + else + { + detached_item = cJSON_DetachItemFromObject(parent, (char*)child_pointer); + } } else { diff --git a/tests/json-patch-tests/cjson-utils-tests.json b/tests/json-patch-tests/cjson-utils-tests.json index 28a5e3073..07a9e3c25 100644 --- a/tests/json-patch-tests/cjson-utils-tests.json +++ b/tests/json-patch-tests/cjson-utils-tests.json @@ -87,5 +87,23 @@ "doc": {"foo": {"bar": 1}}, "patch": [{"op": "add", "path": "/foo/bar/baz", "value": "5"}], "error": "attempting to add to subfield of non-object" - } + }, + { + "comment": "16", + "doc": {"Role": "user", "role": "admin"}, + "patch": [{"op": "remove", "path": "/role"}], + "expected": {"Role": "user"} + }, + { + "comment": "17", + "doc": {"Role": "user", "role": "admin"}, + "patch": [{"op": "replace", "path": "/role", "value": "guest"}], + "expected": {"Role": "user", "role": "guest"} + }, + { + "comment": "18", + "doc": {"A": 1}, + "patch": [{"op": "remove", "path": "/a"}], + "error": "member names are case sensitive" + } ]