16 printf(
"Usage: tab2json [-|filename.tab] [-|filename.json]\n");
20 if (argv[1][0] ==
'-')
26 fpi = fopen(argv[1],
"r");
29 if (argv[2][0] ==
'-')
35 fpo = fopen(argv[2],
"w");
38 if (fpi ==
nullptr || fpo ==
nullptr)
40 printf(
"Usage: tab2json [-|filename.tab] [-|filename.json]\n");
44 if (fgets(buf, 1000, fpi) ==
nullptr)
50 while (fgets(buf, 1000, fpi) !=
nullptr)
54 for (uint16_t
i=0;
i<fields.size(); ++
i)
56 if (fields[
i].find(
"event_utc") == 0)
60 else if (fields[i].find(
"event_name") == 0)
64 else if (fields[i].find(
"event_type") == 0)
66 jobject.
addElement(fields[i], stoi(values[i]));
68 else if (fields[i].find(
"event_flag") == 0)
70 jobject.
addElement(fields[i], stoi(values[i]));
72 else if (fields[i].find(
"event_data") == 0)
76 else if (fields[i].find(
"event_condition") == 0)
78 if (values[i][0] ==
'"')
80 jobject.
addElement(fields[i], values[i].substr(1,values[i].size()-2));
int i
Definition: rw_test.cpp:37
string skip_undesired(string input)
Definition: tab2json.cpp:93
#define GENERAL_ERROR_ARGS
Definition: cosmos-errno.h:305
Definition: jsonobject.h:5
void addElement(string key, JSONValue value)
Definition: jsonobject.cpp:10
char buf[128]
Definition: rw_test.cpp:40
string to_json_string()
Definition: jsonobject.cpp:91
vector< string > string_split(string in, string delimeters)
Parse a string.
Definition: stringlib.cpp:47