Browse Source

Util: Implement Json::Value type customization for print formatting

master
Riyyi 2 years ago
parent
commit
75034a2c5a
  1. 6
      src/util/json/value.cpp
  2. 3
      src/util/json/value.h

6
src/util/json/value.cpp

@ -12,6 +12,7 @@
#include <string>
#include <utility> // move, swap
#include "util/format/format.h"
#include "util/json/array.h"
#include "util/json/job.h"
#include "util/json/object.h"
@ -331,4 +332,9 @@ std::ostream& operator<<(std::ostream& output, const Value& value)
return output << value.dump(4);
}
void format(FormatBuilder& builder, const Value& value)
{
builder.putString(value.dump(4));
}
} // namespace Json

3
src/util/json/value.h

@ -14,6 +14,7 @@
#include <string>
#include <utility> // forward
#include "util/format/format.h"
#include "util/json/fromjson.h"
#include "util/json/tojson.h"
@ -134,6 +135,8 @@ private:
std::istream& operator>>(std::istream& input, Value& value);
std::ostream& operator<<(std::ostream& output, const Value& value);
void format(FormatBuilder& builder, const Value& value);
} // namespace Json
/**

Loading…
Cancel
Save