資源簡(jiǎn)介
使用MDK附加cjson的PACK,進(jìn)行JSON的解析
代碼片段和文件信息
/***********************************************************************************
{
????????“message“: “json?test“
????????“allRowCount“: 2
????????“root“: [{
????????????????????????“value“: “2015-11-16?11:15“
????????????????????????“id“: “2015_20110.10000“
????????????????????????“sex“: “famale“
????????????????}]
????????“success“: “true“
}
************************************************************************************/
#include?
#include?
#include?
?
#include?“cJSON.h“
static?int?print_jsom(char?*json_string)
{
????char?*out;
/*?declarations?*/
????char?*buf?=?NULL;
????size_t?len?=?0;
????cJSON?*jsonroot?=?cJSON_Parse(json_string);
????out=cJSON_Print(jsonroot);
????printf(“%s\n“out);
????/*?create?buffer?to?succeed?*/
????/*?the?extra?5?bytes?are?because?of?inaccuracies?when?reserving?memory?*/
????len?=?strlen(out)?+?5;
????buf?=?(char*)malloc(len);
????if?(buf?==?NULL)
????{
????????printf(“Fail
評(píng)論
共有 條評(píng)論