C/C++中遍历cJSON数据

C/C++中遍历cJSON数据

#include <stdio.h>
#include "iostream"
#include <string.h>
#include "cJSON.h"

int printf_json(cJSON *jsonData)
{
    
    
   if(jsonData == NULL)
   	return 0;
   cJSON *p = jsonData;
   cJSON * desData = p;
   p = p->next;
   if(p == NULL)
   	return 0;
   while( p != NULL)
   {
    
    
	desData = p->prev;
	printf(" %s %s \n",destData->string,destData->valuestring);//前面一个为字段名,后面一个为对应字段名的值。
	p = p->next;
   }
return 0;
}

猜你喜欢

转载自blog.csdn.net/c13055215176/article/details/112181337
今日推荐