reformatting: cJSON_ReplaceItemInObject

This commit is contained in:
Max Bruckner 2016-09-30 10:46:49 +07:00
parent dc8eb30467
commit 3a8043273e

16
cJSON.c
View File

@ -1825,7 +1825,21 @@ void cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem)
cJSON_Delete(c); cJSON_Delete(c);
} }
void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem){int i=0;cJSON *c=object->child;while(c && cJSON_strcasecmp(c->string,string))i++,c=c->next;if(c){newitem->string=cJSON_strdup(string);cJSON_ReplaceItemInArray(object,i,newitem);}} void cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem)
{
int i = 0;
cJSON *c = object->child;
while(c && cJSON_strcasecmp(c->string, string))
{
i++;
c = c->next;
}
if(c)
{
newitem->string = cJSON_strdup(string);
cJSON_ReplaceItemInArray(object, i, newitem);
}
}
/* Create basic types: */ /* Create basic types: */
cJSON *cJSON_CreateNull(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_NULL;return item;} cJSON *cJSON_CreateNull(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_NULL;return item;}