Skip to content

Commit

Permalink
improve: use unformatted json
Browse files Browse the repository at this point in the history
  • Loading branch information
Naplesoul committed Mar 30, 2022
1 parent e6ca0c6 commit 99eb940
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 4 additions & 2 deletions Clients/Camera/BlockTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ std::string BlockTracker::toString()
blk_arr.append(blk);
}
msg_json["blocks"] = blk_arr;
return msg_json.toStyledString();
return Json::FastWriter().write(msg_json);
// return msg_json.toStyledString();
}

std::string BlockTracker::toHeartbeatString()
Expand All @@ -95,7 +96,8 @@ std::string BlockTracker::toHeartbeatString()
msg_json["y"] = y;
msg_json["w"] = actual_width;
msg_json["h"] = actual_height;
return msg_json.toStyledString();
return Json::FastWriter().write(msg_json);
// return msg_json.toStyledString();
}

bool BlockTracker::calibrate(cv::Mat &frame)
Expand Down
3 changes: 2 additions & 1 deletion Server/Objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ Json::Value Object::toJson()

std::string Object::toJsonString()
{
return toJson().toStyledString();
return Json::FastWriter().write(toJson());
// return toJson().toStyledString();
}

Point Block::getPosition(TimePoint cur_time)
Expand Down
6 changes: 4 additions & 2 deletions Server/Scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ void Scheduler::sendTasks()
arr.append(b.second->toJson());
v["blocks"] = arr;

udp_server->send2(arm->client_id, v.toStyledString());
udp_server->send2(arm->client_id, Json::FastWriter().write(v));
// udp_server->send2(arm->client_id, v.toStyledString());
}

if (scada) {
Expand All @@ -171,7 +172,8 @@ void Scheduler::sendTasks()
v["blocks"] = blk_arr;
v["cameras"] = cam_arr;

udp_server->send2(scada->client_id, v.toStyledString());
udp_server->send2(scada->client_id, Json::FastWriter().write(v));
// udp_server->send2(scada->client_id, v.toStyledString());
}
}

Expand Down

0 comments on commit 99eb940

Please sign in to comment.