From abba018da3c2c8011b1485ee8e9e5b2690659c76 Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Sat, 14 Oct 2017 21:40:34 +0500 Subject: 2017-10-14 --- src/Chat.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/Chat.cpp (limited to 'src/Chat.cpp') diff --git a/src/Chat.cpp b/src/Chat.cpp new file mode 100644 index 0000000..0857d6c --- /dev/null +++ b/src/Chat.cpp @@ -0,0 +1,36 @@ +#include "Chat.hpp" + +#include +#include + +Chat::Chat(const std::string &str) { + using nlohmann::json; + json j = json::parse(str); + + /*LOG(WARNING) << j.dump(4); + + std::function iterating = [&](json::iterator iter) { + json val = *iter; + + if (val.is_object() && val.find("text") != val.end()) { + text.append(val["text"].get()); + } + + if (val.is_array() || val.is_object()) { + for (auto it = val.begin(); it != val.end(); ++it) { + iterating(it); + } + } + }; + + for (auto it = j.begin(); it != j.end(); ++it) { + iterating(it); + }*/ + + text = j.dump(4); +} + +std::string Chat::ToJson() const { + throw std::logic_error("Chat not deserealizable"); + return text; +} \ No newline at end of file -- cgit v1.2.3