Add cJSON_Duplicate() function from upstream source.

This commit is contained in:
Eliot Gable
2013-02-11 18:53:37 +00:00
parent 89980756c4
commit 10b8145497
2 changed files with 34 additions and 0 deletions
+7
View File
@@ -114,6 +114,13 @@ SWITCH_DECLARE(void) cJSON_DeleteItemFromObject(cJSON *object,const char *stri
SWITCH_DECLARE(void) cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem);
SWITCH_DECLARE(void) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
/* Duplicate a cJSON item */
SWITCH_DECLARE(cJSON *) cJSON_Duplicate(cJSON *item,int recurse);
/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
need to be released. With recurse!=0, it will duplicate any children connected to the item.
The item->next and ->prev pointers are always zero on return from Duplicate. */
#define cJSON_AddNullToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateNull())
#define cJSON_AddTrueToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue())
#define cJSON_AddFalseToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateFalse())