3 #include "rapidjson/filereadstream.h"
4 #include "rapidjson/stringbuffer.h"
8 #define PRETTY_JSON_OUTPUT 0
9 #if PRETTY_JSON_OUTPUT == 1
10 #include "rapidjson/prettywriter.h"
12 #include "rapidjson/writer.h"
186 std::ofstream
of(filename);
190 rapidjson::StringBuffer strbuf;
191 #if PRETTY_JSON_OUTPUT == 1
192 rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(strbuf);
194 rapidjson::Writer<rapidjson::StringBuffer> writer(strbuf);
197 of << strbuf.GetString();
241 std::unordered_map<std::string, std::string> retval;
242 rapidjson::Document doc;
243 doc.Parse(json_string.c_str());
246 for (rapidjson::Value::ConstMemberIterator it = doc.GetObject().MemberBegin(); it != doc.GetObject().MemberEnd(); ++it)
248 retval[it->name.GetString()] = it->value.GetString();
256 rapidjson::StringBuffer s;
257 rapidjson::Writer<rapidjson::StringBuffer> writer(s);
258 rapidjson::Document d;
260 for (
auto it = key_values.begin(); it != key_values.end(); ++it)
262 rapidjson::Value k(it->first, d.GetAllocator());
263 rapidjson::Value v(it->second, d.GetAllocator());
264 d.AddMember(k, v, d.GetAllocator());
267 return s.GetString();
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation and configuration files Object form shall mean any form resulting from mechanical transformation or translation of a Source including but not limited to compiled object generated and conversions to other media types Work shall mean the work of whether in Source or Object made available under the as indicated by a copyright notice that is included in or attached to the whether in Source or Object that is based or other modifications as a an original work of authorship For the purposes of this Derivative Works shall not include works that remain separable or merely the Work and Derivative Works thereof Contribution shall mean any work of including the original version of the Work and any modifications or additions to that Work or Derivative Works that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner For the purposes of this submitted means any form of or written communication sent to the Licensor or its including but not limited to communication on electronic mailing source code control and issue tracking systems that are managed or on behalf of
JsonWriteArray & operator<<(const std::string &txt)
virtual void finalize(JsonWriteComplex *cplx) override
JsonWriteObject & add_object()
JsonWriteArray & add_array()
std::vector< JsonWriteData * > mChildData
friend class JsonWriteArray
rapidjson::Value mRapidValue
virtual ~JsonWriteComplex()
virtual void finalize(JsonWriteComplex *cplx)=0
friend class JsonWriteObject
JsonWriteData(const std::string &tag, JsonWriteComplex *parent)
JsonWriteComplex * mParent
friend class JsonWriteComplex
JsonWriteData & operator=(const std::string &txt)
virtual rapidjson::Document::AllocatorType & allocator()
bool serialize(const std::string &filename)
rapidjson::Document mRapidDocument
virtual void finalize(JsonWriteComplex *cplx) override
virtual void add_member(rapidjson::Document::ValueType &&name, rapidjson::Document::ValueType &&value, rapidjson::Document::AllocatorType &allocator) override
virtual rapidjson::Document::AllocatorType & allocator() override
JsonWriteData & operator[](const std::string &tag)
friend class JsonWriteData
JsonWriteObject & add_object(const std::string &tag)
virtual void add_member(rapidjson::Document::ValueType &&name, rapidjson::Document::ValueType &&value, rapidjson::Document::AllocatorType &allocator)
virtual void finalize(JsonWriteComplex *cplx) override
JsonWriteArray & add_array(const std::string &tag)
std::unordered_map< std::string, std::string > stringToDictionary(const std::string &json_string)
std::string dictionaryToString(const std::unordered_map< std::string, std::string > &key_values)