More compact JSON formatting.
This commit is contained in:
parent
7eaf7764f7
commit
a8e86c3530
6 changed files with 16 additions and 5 deletions
12
src/3rdparty/rapidjson/prettywriter.h
vendored
12
src/3rdparty/rapidjson/prettywriter.h
vendored
|
@ -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();
|
||||
}
|
||||
|
|
2
src/3rdparty/rapidjson/rapidjson.h
vendored
2
src/3rdparty/rapidjson/rapidjson.h
vendored
|
@ -403,7 +403,7 @@ RAPIDJSON_NAMESPACE_END
|
|||
*/
|
||||
#ifndef RAPIDJSON_ASSERT
|
||||
#include <cassert>
|
||||
#define RAPIDJSON_ASSERT(x) assert(x)
|
||||
#define RAPIDJSON_ASSERT(x)
|
||||
#endif // RAPIDJSON_ASSERT
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
|
1
src/3rdparty/rapidjson/writer.h
vendored
1
src/3rdparty/rapidjson/writer.h
vendored
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue