-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Open
Description
const int main_acct_id = 1;
const int hostid = 2;
const int sub_acct_id = 3;
const int device_port = 4;
cJSON_AddNumberToObject(root, "MAIN_ACCOUNT_ID", main_acct_id);
cJSON_AddNumberToObject(root, "OBJECT_ID", hostid);
cJSON_AddNumberToObject(root, "SUB_ACCOUNT_ID", sub_acct_id);
cJSON_AddNumberToObject(root, "OBJECT_DEVICE_PORT", device_port);
printf("main_acct_id: %d\n", main_acct_id);
printf("hostid: %d\n", hostid);
printf("sub_acct_id: %d\n", sub_acct_id);
printf("device_port: %d\n", device_port);
char *json_str = cJSON_Print(root);
if (!json_str)
{
cJSON_Delete(root);
return;
}
printf("%s\n", json_str);
tmp1 = cJSON_AddNumberToObject(root, "MAIN_ACCOUNT_ID", main_acct_id);
if (!tmp1)
{
printf("MAIN_ACCOUNT_ID is NULL\n");
}
printf("MAIN_ACCOUNT_ID: %d\n", tmp1->valueint);
cJSON_AddNumberToObject(root, "OBJECT_ID", hostid);
if (!tmp1)
{
printf("OBJECT_ID is NULL\n");
}
printf("OBJECT_ID: %d\n", tmp1->valueint);
cJSON_AddNumberToObject(root, "SUB_ACCOUNT_ID", sub_acct_id);
if (!tmp1)
{
printf("SUB_ACCOUNT_ID is NULL\n");
}
printf("SUB_ACCOUNT_ID: %d\n", tmp1->valueint);
cJSON_AddNumberToObject(root, "OBJECT_DEVICE_PORT", device_port);
if (!tmp1)
{
printf("OBJECT_DEVICE_PORT is NULL\n");
}
printf("OBJECT_DEVICE_PORT: %d\n", tmp1->valueint);
Metadata
Metadata
Assignees
Labels
No labels