int array_size = cJSON_GetArraySize(js_list); printf("array size is %d\n",array_size); int i = 0; cJSON *item; for(i=0; i< array_size; i++) { item = cJSON_GetArrayItem(js_list, i); printf("item type is %d\n",item->type); printf("%s\n",item->valuestring); } ...
CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(constint*numbers,intcount);23CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(constfloat*numbers,intcount);24CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(constdouble*numbers,intcount);25CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(constchar**string...
if(result_arr->type == cJSON_Array) { // rt_kprintf("result is array\n"); //由于提前知道数组results只包含1个元素,因此不用再调用cJSON_GetArraySize来获取元素个数,而是直接读第0个元素的值 result = cJSON_GetArrayItem(result_arr, 0);//在数组result_arr中检索第0个元素 if(result->type ...
/* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */ struct cJSON *next; struct cJSON *prev; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */ ...
int cJSON_GetArraySize(const cJSON *array); args description value 数组类型的JSON结构体 获取JSON数组成员 cJSON *cJSON_GetArrayItem(const cJSON *array, int index); args description array 数组类型的JSON结构体 index 数组成员索引 获取JSON对象成员 ...
int cJSON_GetArraySize(const cJSON *array); args description value 数组类型的JSON结构体 获取JSON数组成员 cJSON *cJSON_GetArrayItem(const cJSON *array, int index); args description array 数组类型的JSON结构体 index 数组成员索引 获取JSON对象成员 cJSON *cJSON_GetObjectItemCaseSensitive(const cJSO...
cJSON*root,*item,*obj,*obj1,*array;root=cJSON_Parse(str);item=cJSON_GetObjectItem(root,"id");printf("id=%d\n",item->valueint);obj=cJSON_GetObjectItem(root,"dp");array=cJSON_GetObjectItem(obj,"temperature");intsize=cJSON_GetArraySize(array);inti;for(i=0;i<size;i++){obj1=c...
struct cJSON *next,*prev; /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */ struct cJSON *child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */ struct cJS...
for(int i=0; i<cJSON_GetArraySize(root); i++) //遍历最外层json键值对 { cJSON * item = cJSON_GetArrayItem(root, i); if(cJSON_Object == item->type) //如果对应键的值仍为cJSON_Object就递归调用printJson printJson(item); else //值不为json对象就直接打印出键和值 { printf("%s-...