Skip to content

Commit 14eda96

Browse files
committed
Add json parsing to modem streaming
1 parent df8372a commit 14eda96

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/modem/stream-command.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,19 @@ bool StreamCommand::execute(const String& command,
2323
}
2424

2525
bool running = true;
26+
DynamicJsonBuffer buffer;
2627
while(running) {
2728
if (stream->available()) {
2829
std::string json;
2930
FirebaseStream::Event event = stream->read(json);
3031
out->print("+");
3132
out->print(FirebaseStream::EventToName(event).c_str());
3233
out->print(" ");
33-
// TODO(edcoyne): add json parsing and get real path.
34-
out->println("/dummy/path");
35-
out->println(json.length());
36-
out->println(json.c_str());
34+
const auto& object = buffer.parseObject(json.c_str());
35+
String data = object["data"];
36+
out->println(object["path"].asString());
37+
out->println(data.length());
38+
out->println(data);
3739
} else if (in->available()) {
3840
String command = in->readLine();
3941
if (command == "END_STREAM") {

0 commit comments

Comments
 (0)