Skip to content

Commit 0934013

Browse files
committed
Fix processStdinDataJson to handle JSON input
- Add else branch for JSON input format in processStdinDataJson - Previously only CSV input was handled, JSON stdin was silently ignored
1 parent 41a854e commit 0934013

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/sensor_data_transformer.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,23 @@ void SensorDataTransformer::processStdinDataJson(const std::vector<std::string>&
228228
writeJsonObject(reading, outfile, removeWhitespace);
229229
outfile << sp << "]";
230230
}
231+
} else {
232+
// JSON input format (including "auto" which defaults to JSON for stdin)
233+
for (const auto& line : lines) {
234+
if (line.empty()) continue;
235+
236+
auto readings = JsonParser::parseJsonLine(line);
237+
for (const auto& reading : readings) {
238+
if (reading.empty()) continue;
239+
if (!shouldOutputReading(reading)) continue;
240+
241+
if (!firstOutput) outfile << "\n";
242+
firstOutput = false;
243+
outfile << "[" << sp;
244+
writeJsonObject(reading, outfile, removeWhitespace);
245+
outfile << sp << "]";
246+
}
247+
}
231248
}
232249
}
233250

0 commit comments

Comments
 (0)