1
0
mirror of https://github.com/xmrig/xmrig.git synced 2025-12-09 00:33:33 -05:00

More compact JSON formatting.

This commit is contained in:
XMRig
2019-08-04 22:07:05 +07:00
parent 7eaf7764f7
commit a8e86c3530
6 changed files with 16 additions and 5 deletions

View File

@@ -164,9 +164,10 @@ public:
(void)memberCount;
RAPIDJSON_ASSERT(Base::level_stack_.GetSize() >= sizeof(typename Base::Level));
RAPIDJSON_ASSERT(Base::level_stack_.template Top<typename Base::Level>()->inArray);
bool empty = Base::level_stack_.template Pop<typename Base::Level>(1)->valueCount == 0;
typename Base::Level* level = Base::level_stack_.template Pop<typename Base::Level>(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<typename Base::Level>();
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();
}