MCPcopy Create free account
hub / github.com/Tencent/Hardcoder / replace_item_in_object

Function replace_item_in_object

libapp2sys/src/main/cpp/cjson/cJSON.c:2223–2241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2221}
2222
2223static cJSON_bool replace_item_in_object(cJSON *object, const char *string, cJSON *replacement, cJSON_bool case_sensitive)
2224{
2225 if ((replacement == NULL) || (string == NULL))
2226 {
2227 return false;
2228 }
2229
2230 /* replace the name in the replacement */
2231 if (!(replacement->type & cJSON_StringIsConst) && (replacement->string != NULL))
2232 {
2233 cJSON_free(replacement->string);
2234 }
2235 replacement->string = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks);
2236 replacement->type &= ~cJSON_StringIsConst;
2237
2238 cJSON_ReplaceItemViaPointer(object, get_object_item(object, string, case_sensitive), replacement);
2239
2240 return true;
2241}
2242
2243CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem)
2244{

Calls 4

cJSON_freeFunction · 0.85
cJSON_strdupFunction · 0.85
get_object_itemFunction · 0.85

Tested by

no test coverage detected