From 684108d833ee92f15c1b746cf139929da2a31735 Mon Sep 17 00:00:00 2001 From: Andrej Babic Date: Tue, 2 Jun 2020 12:18:08 +0200 Subject: [PATCH] Fixed writing JSON error --- sf-stream/src/main.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/sf-stream/src/main.cpp b/sf-stream/src/main.cpp index e977c45..6ecd3b5 100644 --- a/sf-stream/src/main.cpp +++ b/sf-stream/src/main.cpp @@ -72,10 +72,7 @@ int main (int argc, char *argv[]) rapidjson::Document header(rapidjson::kObjectType); auto& header_alloc = header.GetAllocator(); - - rapidjson::StringBuffer header_buffer; - rapidjson::Writer header_writer(header_buffer); - header.Accept(header_writer); + string text_header; // TODO: Remove stats trash. int stats_counter = 0; @@ -176,7 +173,14 @@ int main (int argc, char *argv[]) shape[1] = 2; } - string text_header = header_buffer.GetString(); + + { + rapidjson::StringBuffer buffer; + rapidjson::Writer writer(buffer); + header.Accept(writer); + + text_header = buffer.GetString(); + } zmq_send(socket_streamvis, text_header.c_str(), @@ -210,7 +214,13 @@ int main (int argc, char *argv[]) shape[1] = 2; } - text_header = header_buffer.GetString(); + { + rapidjson::StringBuffer buffer; + rapidjson::Writer writer(buffer); + header.Accept(writer); + + text_header = buffer.GetString(); + } zmq_send(socket_live, text_header.c_str(),