diff --git a/src/3rdparty/rapidjson/prettywriter.h b/src/3rdparty/rapidjson/prettywriter.h index 45afb694..c7c29b21 100644 --- a/src/3rdparty/rapidjson/prettywriter.h +++ b/src/3rdparty/rapidjson/prettywriter.h @@ -164,9 +164,10 @@ public: (void)memberCount; RAPIDJSON_ASSERT(Base::level_stack_.GetSize() >= sizeof(typename Base::Level)); RAPIDJSON_ASSERT(Base::level_stack_.template Top()->inArray); - bool empty = Base::level_stack_.template Pop(1)->valueCount == 0; + typename Base::Level* level = Base::level_stack_.template Pop(1); + bool empty = level->valueCount == 0; - if (!empty && !(formatOptions_ & kFormatSingleLineArray)) { + if (!empty && !level->inLine) { Base::os_->Put('\n'); WriteIndent(); } @@ -211,13 +212,16 @@ protected: typename Base::Level* level = Base::level_stack_.template Top(); if (level->inArray) { + level->inLine = (formatOptions_ & kFormatSingleLineArray) && type != kObjectType && type != kArrayType; + if (level->valueCount > 0) { Base::os_->Put(','); // add comma if it is not the first element in array - if (formatOptions_ & kFormatSingleLineArray) + if (level->inLine) { Base::os_->Put(' '); + } } - if (!(formatOptions_ & kFormatSingleLineArray)) { + if (!level->inLine) { Base::os_->Put('\n'); WriteIndent(); } diff --git a/src/3rdparty/rapidjson/rapidjson.h b/src/3rdparty/rapidjson/rapidjson.h index 549936ff..78c8aae0 100644 --- a/src/3rdparty/rapidjson/rapidjson.h +++ b/src/3rdparty/rapidjson/rapidjson.h @@ -403,7 +403,7 @@ RAPIDJSON_NAMESPACE_END */ #ifndef RAPIDJSON_ASSERT #include -#define RAPIDJSON_ASSERT(x) assert(x) +#define RAPIDJSON_ASSERT(x) #endif // RAPIDJSON_ASSERT /////////////////////////////////////////////////////////////////////////////// diff --git a/src/3rdparty/rapidjson/writer.h b/src/3rdparty/rapidjson/writer.h index 6f5b6903..1d33b2f9 100644 --- a/src/3rdparty/rapidjson/writer.h +++ b/src/3rdparty/rapidjson/writer.h @@ -288,6 +288,7 @@ protected: Level(bool inArray_) : valueCount(0), inArray(inArray_) {} size_t valueCount; //!< number of values in this level bool inArray; //!< true if in array, otherwise in object + bool inLine = false; }; static const size_t kDefaultLevelDepth = 32; diff --git a/src/base/io/json/Json_unix.cpp b/src/base/io/json/Json_unix.cpp index eeef9564..dedea947 100644 --- a/src/base/io/json/Json_unix.cpp +++ b/src/base/io/json/Json_unix.cpp @@ -56,6 +56,8 @@ bool xmrig::Json::save(const char *fileName, const rapidjson::Document &doc) rapidjson::OStreamWrapper osw(ofs); rapidjson::PrettyWriter writer(osw); + writer.SetFormatOptions(rapidjson::kFormatSingleLineArray); + doc.Accept(writer); return true; diff --git a/src/base/io/json/Json_win.cpp b/src/base/io/json/Json_win.cpp index 0faccdea..73aff2c5 100644 --- a/src/base/io/json/Json_win.cpp +++ b/src/base/io/json/Json_win.cpp @@ -118,6 +118,8 @@ bool xmrig::Json::save(const char *fileName, const rapidjson::Document &doc) OStreamWrapper osw(ofs); PrettyWriter writer(osw); + writer.SetFormatOptions(kFormatSingleLineArray); + doc.Accept(writer); return true; diff --git a/src/base/net/http/HttpApiResponse.cpp b/src/base/net/http/HttpApiResponse.cpp index bf91445a..5fe92636 100644 --- a/src/base/net/http/HttpApiResponse.cpp +++ b/src/base/net/http/HttpApiResponse.cpp @@ -80,6 +80,8 @@ void xmrig::HttpApiResponse::end() StringBuffer buffer(nullptr, 4096); PrettyWriter writer(buffer); writer.SetMaxDecimalPlaces(10); + writer.SetFormatOptions(kFormatSingleLineArray); + m_doc.Accept(writer); HttpResponse::end(buffer.GetString(), buffer.GetSize());