1
0
cuberite-2a/src/JsonUtils.cpp
peterbell10 e6634ed26c
Update submodules (#4727)
Closes #4708

This updates jsoncpp, mbedtls, TCLAP and SQLiteCpp to their latest stable release. A few additional changes were needed:

* jsoncpp deprecated Reader, FastWriter and StyledWriter which I've replaced
  with some helper functions in JsonUtils.cpp

* SQLiteCpp changed how it builds with external sqlite libraries, now expecting
  them to be installed. The simplest path was to remove sqlite from cuberite's
  submodule and just use SQLiteCpp's internal version.
2020-05-09 15:51:15 +01:00

44 lines
795 B
C++

#include "Globals.h"
#include "JsonUtils.h"
#include "json/json.h"
#include <sstream>
namespace JsonUtils
{
AString WriteFastString(const Json::Value & a_Root)
{
Json::StreamWriterBuilder Builder;
Builder["commentStyle"] = "None";
Builder["indentation"] = "";
return Json::writeString(Builder, a_Root);
}
AString WriteStyledString(const Json::Value & a_Root)
{
Json::StreamWriterBuilder Builder;
return Json::writeString(Builder, a_Root);
}
bool ParseString(const AString & a_JsonStr, Json::Value & a_Root, AString * a_ErrorMsg)
{
Json::CharReaderBuilder Builder;
std::unique_ptr<Json::CharReader> Reader(Builder.newCharReader());
const char * Doc = a_JsonStr.data();
return Reader->parse(Doc, Doc + a_JsonStr.size(), &a_Root, a_ErrorMsg);
}
} // namespace JsonUtils