From 3a8043273ebc7983cac59c0247c159506bc56418 Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Fri, 30 Sep 2016 10:46:49 +0700 Subject: [PATCH] reformatting: cJSON_ReplaceItemInObject --- cJSON.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/cJSON.c b/cJSON.c index 0228ef7..5c3dc59 100644 --- a/cJSON.c +++ b/cJSON.c @@ -1825,7 +1825,21 @@ void cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem) 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: */ cJSON *cJSON_CreateNull(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_NULL;return item;}