Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion cJSON_Utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
20 changes: 19 additions & 1 deletion tests/json-patch-tests/cjson-utils-tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]