0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 12:12:15 +02:00

jsonhelper: added format() method outputting to Buffer.

Signed-off-by: James Yonan <james@openvpn.net>
This commit is contained in:
James Yonan 2017-09-23 16:41:50 -06:00 committed by Lev Stipakov
parent 407b83e529
commit 04c3aa9b0a
No known key found for this signature in database
GPG Key ID: 88670BE258B9C258

View File

@ -478,6 +478,15 @@ namespace openvpn {
return buf_to_string(*bp);
}
inline void format(const Json::Value& root, Buffer& buf)
{
Json::StreamWriterBuilder json_builder;
json_builder.settings_["indentation"] = " ";
BufferStreamOut os(buf);
std::unique_ptr<Json::StreamWriter> sw(json_builder.newStreamWriter());
sw->write(root, &os);
}
inline std::string format(const Json::Value& root)
{
return root.toStyledString();