I want to parse the json {"endtime":"<timestamp>", "status":"on"}
and the timestamp contains something like 3/27/2019 7:40:47 AM
.
my code is given below:
cJSON * root = cJSON_Parse(buffer);
cJSON * name = cJSON_GetObjectItem(root, "status");
cJSON * sum = cJSON_GetObjectItem(root, "endtime");
res = strcmp(name->valuestring, "ON");
printf("timestamp = %s \n", sum->valuestring);
char str1[20];
char str[5];
strcpy(str, name->valuestring);
strcpy(str1, sum->valuestring);
I want to check whether the status contain on/off and get timestamp from endtime.
Is this the right way to parse?