C/C++中遍历cJSON数据

C/C++中遍历cJSON数据

#include 
#include "iostream"
#include 
#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;
}

你可能感兴趣的:(c/c++,json)