2323#include < curl/curl.h>
2424#include < sstream>
2525#include < json/reader.h>
26+ #include < json/writer.h>
2627#ifdef _WIN32
2728#include < wincrypt.h>
2829#include < windows.h>
@@ -170,6 +171,14 @@ std::string JobSender::generate_url(const std::string &endpoint) {
170171 return url;
171172}
172173
174+ std::string JobSender::json_to_string (const Json::Value &json) {
175+ Json::StreamWriterBuilder builder;
176+
177+ builder[" indentation" ] = " " ;
178+
179+ return Json::writeString (builder, json);
180+ }
181+
173182bool JobSender::query_capabilities () {
174183 std::string url = generate_url (" capabilities" );
175184 wxString response;
@@ -214,7 +223,7 @@ bool JobSender::send_job() {
214223
215224 job.Serialize (json);
216225
217- long code = send_data (url, json. toStyledString ( ).c_str (), response, error);
226+ long code = send_data (url, json_to_string (json ).c_str (), response, error);
218227 if (code != 200L ) {
219228 auto event = new wxThreadEvent (wxEVT_COMMAND_THREAD, wxID_ABORT);
220229 event->SetString (" API returned error code: " + std::to_string (code) + " " + error);
@@ -247,7 +256,7 @@ void JobSender::send_truck() {
247256 json[" speed" ] = truck.speed ;
248257 truck.position .Serialize (json);
249258
250- send_data (url, json. toStyledString ( ).c_str (), response, error);
259+ send_data (url, json_to_string (json ).c_str (), response, error);
251260}
252261
253262void JobSender::send_fine () {
@@ -268,7 +277,7 @@ void JobSender::send_fine() {
268277
269278 fine.Serialize (json);
270279
271- long code = send_data (url, json. toStyledString ( ).c_str (), response, error);
280+ long code = send_data (url, json_to_string (json ).c_str (), response, error);
272281 if (code != 200L ) {
273282 LockGuard lock (m_lock);
274283 m_fine_queue.push_front (fine);
0 commit comments