eg:
{
"oper": 147,
"data": {
"codes": ["0755VF", "0756SB", "0734OP"],
"ids": [1,2,3,4],
}
}
char *pResponse;
cJSON *root, *json_oper, *json_data, *json_ids, *json_codes;
root = cJSON_CreateObject();
cJSON_AddNumberToObject(root, "oper", operid);
json_data = cJSON_CreateObject();
cJSON_AddItemToObject(root, "data", json_data);
json_codes = cJSON_CreateArray();
json_ids = cJSON_CreateArray();
for(i =0; i<num; i++)
{
cJSON_AddItemToArray(json_codes, cJSON_CreateString("0755VF"));
cJSON_AddItemToArray(json_src, cJSON_CreateNumber(i));
}
cJSON_AddItemToObject(json_data, "codes", json_codes);
cJSON_AddItemToObject(json_data, "srcids", json_ids);
pResponse = cJSON_Print(root);