30static void csv_addjsonfield(FILE* reportfile,
const cJSON* json,
char* fieldname) {
31 char* text =
json2text(cJSON_GetObjectItemCaseSensitive(json, fieldname));
38 "field1,field2,field3\r\n"
46 samples_json = cJSON_Parse(
"["
47 "{\"field1\":\"value1\",\"field2\":\"value 2\",\"field3\":\" value3\"},"
48 "{\"field1\":\"value4 \",\"field2\":\"value,5\",\"field3\":\"value\\\"6\\\"\"}"
50 const cJSON* sample_json;
53 csv_addjsonfield(reportfile, sample_json,
"field1");
54 csv_addjsonfield(reportfile, sample_json,
"field2");
55 csv_addjsonfield(reportfile, sample_json,
"field3");
59 cJSON_Delete(samples_json);
#define cJSON_ArrayForEach(element, array)
void csv_addfield(FILE *reportfile, const char *value)
void csv_addline(FILE *reportfile)
char * json2text(cJSON *value_json)
Convert a cJSON object in a C String.
Wrapper around cJSON library with helpers.
void report_sample(FILE *reportfile, const cluster_t *cluster)
void report_sample_header(FILE *reportfile)
Basic report without connection to test output format.