Lines Matching refs:patch
759 static enum patch_operation decode_patch_operation(const cJSON * const patch, const cJSON_bool case_sensitive)
761 cJSON *operation = get_object_item(patch, "op", case_sensitive);
824 static int apply_patch(cJSON *object, const cJSON *patch, const cJSON_bool case_sensitive)
834 path = get_object_item(patch, "path", case_sensitive);
837 /* malformed patch. */
842 opcode = decode_patch_operation(patch, case_sensitive);
851 status = !compare_json(get_item_from_pointer(object, path->valuestring, case_sensitive), get_object_item(patch, "value", case_sensitive), case_sensitive);
870 value = get_object_item(patch, "value", case_sensitive);
925 cJSON *from = get_object_item(patch, "from", case_sensitive);
960 value = get_object_item(patch, "value", case_sensitive);
1115 cJSON *patch = NULL;
1122 patch = cJSON_CreateObject();
1123 if (patch == NULL)
1127 cJSON_AddItemToObject(patch, "op", cJSON_CreateString((const char*)operation));
1131 cJSON_AddItemToObject(patch, "path", cJSON_CreateString((const char*)path));
1142 cJSON_AddItemToObject(patch, "path", cJSON_CreateString((const char*)full_path));
1148 cJSON_AddItemToObject(patch, "value", cJSON_Duplicate(value, 1));
1150 cJSON_AddItemToArray(patches, patch);
1268 /* create a patch for the element */
1338 static cJSON *merge_patch(cJSON *target, const cJSON * const patch, const cJSON_bool case_sensitive)
1342 if (!cJSON_IsObject(patch))
1346 return cJSON_Duplicate(patch, 1);
1355 patch_child = patch->child;
1398 CJSON_PUBLIC(cJSON *) cJSONUtils_MergePatch(cJSON *target, const cJSON * const patch)
1400 return merge_patch(target, patch, false);
1403 CJSON_PUBLIC(cJSON *) cJSONUtils_MergePatchCaseSensitive(cJSON *target, const cJSON * const patch)
1405 return merge_patch(target, patch, true);
1412 cJSON *patch = NULL;
1415 /* patch to delete everything */
1428 patch = cJSON_CreateObject();
1429 if (patch == NULL)
1455 cJSON_AddItemToObject(patch, from_child->string, cJSON_CreateNull());
1461 /* to has a value that from doesn't have -> add to patch */
1462 cJSON_AddItemToObject(patch, to_child->string, cJSON_Duplicate(to_child, 1));
1471 /* not identical --> generate a patch */
1472 cJSON_AddItemToObject(patch, to_child->string, cJSONUtils_GenerateMergePatch(from_child, to_child));
1480 if (patch->child == NULL)
1482 /* no patch generated */
1483 cJSON_Delete(patch);
1487 return patch;