mirror-chatterino2/src/util/RapidjsonHelpers.cpp

33 lines
904 B
C++
Raw Normal View History

2018-06-26 14:09:39 +02:00
#include "util/RapidjsonHelpers.hpp"
#include <rapidjson/prettywriter.h>
namespace chatterino {
namespace rj {
2018-08-15 22:46:20 +02:00
void addMember(rapidjson::Value &obj, const char *key,
rapidjson::Value &&value,
rapidjson::Document::AllocatorType &a)
{
obj.AddMember(rapidjson::Value(key, a).Move(), value, a);
}
2018-08-15 22:46:20 +02:00
void addMember(rapidjson::Value &obj, const char *key,
rapidjson::Value &value,
rapidjson::Document::AllocatorType &a)
{
obj.AddMember(rapidjson::Value(key, a).Move(), value.Move(), a);
}
2018-08-15 22:46:20 +02:00
std::string stringify(const rapidjson::Value &value)
{
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
value.Accept(writer);
2018-08-15 22:46:20 +02:00
return std::string(buffer.GetString());
}
} // namespace rj
} // namespace chatterino