13 printf(
"Usage: json2tab [-|filename.json] [-|filename.tab]\n");
17 if (argv[1][0] ==
'-')
23 fpi = fopen(argv[1],
"r");
26 if (argv[2][0] ==
'-')
32 fpo = fopen(argv[2],
"w");
35 if (fpi ==
nullptr || fpo ==
nullptr)
37 printf(
"Usage: json2tab [-|filename.json] [-|filename.tab]\n");
41 if (fgets(buf, 1000, fpi) ==
nullptr)
46 for (
const auto& member : jobject.ObjectContents)
48 if (member.first.find(
"event_") == 0)
50 fprintf(fpo,
"%s\t", member.first.c_str());
61 for (
const auto& member : jobject.ObjectContents)
64 if (member.first.find(
"event_utc") == 0)
66 fprintf(fpo,
"%f\t", member.second.nvalue);
68 else if (member.first.find(
"event_name") == 0)
70 fprintf(fpo,
"%s\t", member.second.svalue.c_str());
72 else if (member.first.find(
"event_type") == 0)
74 fprintf(fpo,
"%u\t", static_cast<uint32_t>(member.second.nvalue));
76 else if (member.first.find(
"event_flag") == 0)
78 fprintf(fpo,
"%u\t", static_cast<uint32_t>(member.second.nvalue));
80 else if (member.first.find(
"event_data") == 0)
82 fprintf(fpo,
"%s\t", member.second.svalue.c_str());
84 else if (member.first.find(
"event_condition") == 0)
86 fprintf(fpo,
"%s\t", member.second.svalue.c_str());
91 while (fgets(buf, 1000, fpi) !=
nullptr)
94 for (
const auto& member : jobject.ObjectContents)
97 if (member.first.find(
"event_utc") == 0)
99 fprintf(fpo,
"%f\t", member.second.nvalue);
101 else if (member.first.find(
"event_name") == 0)
103 fprintf(fpo,
"%s\t", member.second.svalue.c_str());
105 else if (member.first.find(
"event_type") == 0)
107 fprintf(fpo,
"%u\t", static_cast<uint32_t>(member.second.nvalue));
109 else if (member.first.find(
"event_flag") == 0)
111 fprintf(fpo,
"%u\t", static_cast<uint32_t>(member.second.nvalue));
113 else if (member.first.find(
"event_data") == 0)
115 fprintf(fpo,
"%s\t", member.second.svalue.c_str());
117 else if (member.first.find(
"event_condition") == 0)
119 fprintf(fpo,
"%s\t", member.second.svalue.c_str());
#define GENERAL_ERROR_ARGS
Definition: cosmos-errno.h:305
Definition: jsonclass.h:11
char buf[128]
Definition: rw_test.cpp:40