cJSON

mirror of Dave's cJSON
git clone git://git.thc420.xyz/cJSON
Log | Files | Refs | README | LICENSE

commit e6b352d126a1c22f487a1768c019f502164bf2ba
parent b4151361de7a9a8b8fc786ed7d3c324488bcd261
Author: Dave Gamble <davegamble@gmail.com>
Date:   Sun, 20 Mar 2016 00:21:19 +0000

tidy up some code that was added a while back.

Diffstat:
McJSON.c | 16+++-------------
1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/cJSON.c b/cJSON.c @@ -662,19 +662,9 @@ static char *print_object(cJSON *item,int depth,int fmt,printbuffer *p) /* Get Array size/item / object item. */ int cJSON_GetArraySize(cJSON *array) {cJSON *c=array->child;int i=0;while(c)i++,c=c->next;return i;} -cJSON *cJSON_GetArrayItem(cJSON *array,int item) {cJSON *c; if (array == NULL) return NULL; c=array->child; while (c && item>0) item--,c=c->next; return c;} -cJSON *cJSON_GetObjectItem(cJSON *object,const char *string) {cJSON *c; if (object == NULL) return NULL; c=object->child; while (c && cJSON_strcasecmp(c->string,string)) c=c->next; return c;} -int cJSON_HasObjectItem(cJSON *object,const char *string) { - cJSON *c=object->child; - while (c ) - { - if(cJSON_strcasecmp(c->string,string)==0){ - return 1; - } - c=c->next; - } - return 0; -} +cJSON *cJSON_GetArrayItem(cJSON *array,int item) {cJSON *c=array?array->child:0;while (c && item>0) item--,c=c->next; return c;} +cJSON *cJSON_GetObjectItem(cJSON *object,const char *string) {cJSON *c=object?object->child:0;while (c && cJSON_strcasecmp(c->string,string)) c=c->next; return c;} +int cJSON_HasObjectItem(cJSON *object,const char *string) {return cJSON_GetObjectItem(object,string)?1:0;} /* Utility for array list handling. */ static void suffix_object(cJSON *prev,cJSON *item) {prev->next=item;item->prev=prev;}