diff --git a/src/threading/formatters/JSON.cc b/src/threading/formatters/JSON.cc index 472023e0f8..e1a5713461 100644 --- a/src/threading/formatters/JSON.cc +++ b/src/threading/formatters/JSON.cc @@ -15,7 +15,7 @@ using namespace threading::formatter; -JSON::JSON(MsgThread* t, TimeFormat tf) : Formatter(t) +JSON::JSON(MsgThread* t, TimeFormat tf) : Formatter(t), surrounding_braces(true) { timestamps = tf; } @@ -27,7 +27,8 @@ JSON::~JSON() bool JSON::Describe(ODesc* desc, int num_fields, const Field* const * fields, Value** vals) const { - desc->AddRaw("{"); + if ( surrounding_braces ) + desc->AddRaw("{"); for ( int i = 0; i < num_fields; i++ ) { @@ -41,7 +42,8 @@ bool JSON::Describe(ODesc* desc, int num_fields, const Field* const * fields, return false; } - desc->AddRaw("}"); + if ( surrounding_braces ) + desc->AddRaw("}"); return true; } @@ -217,3 +219,8 @@ threading::Value* JSON::ParseValue(const string& s, const string& name, TypeTag GetThread()->Error("JSON formatter does not support parsing yet."); return NULL; } + +void JSON::SurroundingBraces(bool use_braces) + { + surrounding_braces = use_braces; + } diff --git a/src/threading/formatters/JSON.h b/src/threading/formatters/JSON.h index d7859f83fb..04209fbde9 100644 --- a/src/threading/formatters/JSON.h +++ b/src/threading/formatters/JSON.h @@ -27,8 +27,11 @@ public: threading::Value** vals) const; virtual threading::Value* ParseValue(const string& s, const string& name, TypeTag type, TypeTag subtype = TYPE_ERROR) const; + void SurroundingBraces(bool use_braces); + private: TimeFormat timestamps; + bool surrounding_braces; }; }}