mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
reformatting: cJSON_AddItemToObject
This commit is contained in:
parent
c26f9b918d
commit
196885ad93
18
cJSON.c
18
cJSON.c
@ -1666,7 +1666,23 @@ void cJSON_AddItemToArray(cJSON *array, cJSON *item)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item) {if (!item) return; if (item->string) cJSON_free(item->string);item->string=cJSON_strdup(string);cJSON_AddItemToArray(object,item);}
|
void cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
|
||||||
|
{
|
||||||
|
if (!item)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free old key and set new one */
|
||||||
|
if (item->string)
|
||||||
|
{
|
||||||
|
cJSON_free(item->string);
|
||||||
|
}
|
||||||
|
item->string = cJSON_strdup(string);
|
||||||
|
|
||||||
|
cJSON_AddItemToArray(object,item);
|
||||||
|
}
|
||||||
|
|
||||||
void cJSON_AddItemToObjectCS(cJSON *object,const char *string,cJSON *item) {if (!item) return; if (!(item->type&cJSON_StringIsConst) && item->string) cJSON_free(item->string);item->string=(char*)string;item->type|=cJSON_StringIsConst;cJSON_AddItemToArray(object,item);}
|
void cJSON_AddItemToObjectCS(cJSON *object,const char *string,cJSON *item) {if (!item) return; if (!(item->type&cJSON_StringIsConst) && item->string) cJSON_free(item->string);item->string=(char*)string;item->type|=cJSON_StringIsConst;cJSON_AddItemToArray(object,item);}
|
||||||
void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) {cJSON_AddItemToArray(array,create_reference(item));}
|
void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) {cJSON_AddItemToArray(array,create_reference(item));}
|
||||||
void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item) {cJSON_AddItemToObject(object,string,create_reference(item));}
|
void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item) {cJSON_AddItemToObject(object,string,create_reference(item));}
|
||||||
|
Loading…
Reference in New Issue
Block a user