gaoyaqi的个人主页

http://www.qtcn.org/bbs/u/184992  [收藏] [复制]

gaoyaqi

  • 7

    关注

  • 2

    粉丝

  • 5

    访客

  • 等级:新手上路
  • 总积分:3
  • 保密,1990-08-20

最后登录:2023-12-04

更多资料

日志

JSON-C解析

2017-10-30 17:19
//{"RETCODE":"R20","RETMSG":"OK","MISSDATATIME":["201710301210","201710301205","201710301200"]}


struct json_object *obj=NULL;
    obj = json_tokener_parse(Respond);
    if(obj==NULL)
    {
        printf("json_object obj==NULL\n");
        return -1;
    }

    struct json_object *RETCODE=NULL;
    RETCODE = json_object_object_get(obj, "RETCODE");
    char station_id[52] ={0};
    sprintf(station_id,"%s",  json_object_to_json_string(RETCODE));
    printf(",,,,,,,RETCODE:%s\n",station_id);


    struct json_object *RETMSG=NULL;
    RETMSG = json_object_object_get(obj, "RETMSG");
    char station_id2[52] ={0};
    sprintf(station_id2,"%s",  json_object_to_json_string(RETMSG));
    printf(",,,,,,,RETMSG:%s\n",station_id2);


    struct json_object *MISSDATATIME=NULL;
    MISSDATATIME = json_object_object_get(obj, "MISSDATATIME");
    int n=json_object_array_length(MISSDATATIME);
    char station_id3[52] ={0};
    int i = 0;
    for(i=0;i<n;i++)
    {
        struct json_object *obje=json_object_array_get_idx(MISSDATATIME,i);
        sprintf(station_id3,"%s",  json_object_to_json_string(obje));
        printf("tmime :%s\n",station_id3);

    }
分类:默认分类|回复:0|浏览:461|全站可见|转载
 

Powered by phpwind v8.7 Certificate Copyright Time now is:05-04 04:51
©2005-2016 QTCN开发网 版权所有 Gzip disabled