代码拉取完成,页面将自动刷新
#include "myJson.h"
#include "yyjson.h"
#include <iostream>
int main(void)
{
//------------------JSON-------------------//
MyJson *my_Json = new MyJson;
my_Json->Init(_WRITE_JSON_);
my_Json->AddRootKeyStr("cmd", "get_channel_listܼ");
void *arr = my_Json->CreatJsonArrNum(NULL, 0);
my_Json->AddRootArr(arr, "data");
void *obj = my_Json->CreatJsonObj();
my_Json->AddObjKeyStr(obj, "taskid", "112201602");
my_Json->AddObjKeyStr(obj, "taskname","K259+520_HD");
my_Json->AddObjKeyStr(obj, "address", "192.168.11.41");
my_Json->AddObjKeyStr(obj, "cameraip", "192.168.2.221");
my_Json->AddObjKeyNum(obj, "no", 1);
my_Json->AddObjKeyNum(obj, "run_stat", 1);
my_Json->AddObjKeyNum(obj, "link_stat", 1);
my_Json->AddObjKeyNum(obj, "conn_num", 0);
my_Json->AddArrVal(arr, obj);
char buf[2048] = { 0 };
my_Json->printJsonStr(buf);
//printf("%s\n", buf);
my_Json->Free();
//--------------------JSON------------------//
MyJson *pause_Json = new MyJson;
pause_Json->Init(_PAUSE_JSON_, buf);
char ans[1024] = { 0 };
pause_Json->PauseRootKeyStr("cmd", ans, 1024);
printf("%s\n", ans);
void* arr_obj = pause_Json->PauseRootKeyArr("data");
void* obj_buf[1];
pause_Json->PauseArrElemObj(arr_obj, obj_buf, 1);
/*printf("%s\n", pause_Json->PauseObjElemStr(obj_buf[0], "taskid"));
printf("%s\n", pause_Json->PauseObjElemStr(obj_buf[0], "taskname"));
printf("%s\n", pause_Json->PauseObjElemStr(obj_buf[0], "address"));
printf("%s\n", pause_Json->PauseObjElemStr(obj_buf[0], "cameraip"));*/
printf("%d\n", pause_Json->PauseObjElemNum(obj_buf[0], "no"));
printf("%d\n", pause_Json->PauseObjElemNum(obj_buf[0], "run_stat"));
printf("%d\n", pause_Json->PauseObjElemNum(obj_buf[0], "link_stat"));
printf("%d\n", pause_Json->PauseObjElemNum(obj_buf[0], "conn_num"));
pause_Json->Free();
getchar();
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。