日志
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); } |
下一篇: JSON-C封装