mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
+usefull function
This commit is contained in:
parent
affedd65ba
commit
b175877d8b
11
cJSON.c
11
cJSON.c
@ -661,6 +661,17 @@ static char *print_object(cJSON *item,int depth,int fmt,printbuffer *p)
|
|||||||
int cJSON_GetArraySize(cJSON *array) {cJSON *c=array->child;int i=0;while(c)i++,c=c->next;return i;}
|
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=array->child; while (c && item>0) item--,c=c->next; return c;}
|
cJSON *cJSON_GetArrayItem(cJSON *array,int item) {cJSON *c=array->child; while (c && item>0) item--,c=c->next; return c;}
|
||||||
cJSON *cJSON_GetObjectItem(cJSON *object,const char *string) {cJSON *c=object->child; while (c && cJSON_strcasecmp(c->string,string)) c=c->next; return c;}
|
cJSON *cJSON_GetObjectItem(cJSON *object,const char *string) {cJSON *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;
|
||||||
|
}
|
||||||
|
|
||||||
/* Utility for array list handling. */
|
/* Utility for array list handling. */
|
||||||
static void suffix_object(cJSON *prev,cJSON *item) {prev->next=item;item->prev=prev;}
|
static void suffix_object(cJSON *prev,cJSON *item) {prev->next=item;item->prev=prev;}
|
||||||
|
2
cJSON.h
2
cJSON.h
@ -80,7 +80,7 @@ extern int cJSON_GetArraySize(cJSON *array);
|
|||||||
extern cJSON *cJSON_GetArrayItem(cJSON *array,int item);
|
extern cJSON *cJSON_GetArrayItem(cJSON *array,int item);
|
||||||
/* Get item "string" from object. Case insensitive. */
|
/* Get item "string" from object. Case insensitive. */
|
||||||
extern cJSON *cJSON_GetObjectItem(cJSON *object,const char *string);
|
extern cJSON *cJSON_GetObjectItem(cJSON *object,const char *string);
|
||||||
|
extern int *cJSON_HasObjectItem(cJSON *object,const char *string);
|
||||||
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
|
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
|
||||||
extern const char *cJSON_GetErrorPtr(void);
|
extern const char *cJSON_GetErrorPtr(void);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user