summaryrefslogtreecommitdiffstats
path: root/src/Chat.cpp
blob: 0857d6ca3e8e638b0e49005f8a213640e80302aa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "Chat.hpp"

#include <nlohmann/json.hpp>
#include <easylogging++.h>

Chat::Chat(const std::string &str) {
    using nlohmann::json;
    json j = json::parse(str);

    /*LOG(WARNING) << j.dump(4);

    std::function<void(json::iterator)> iterating = [&](json::iterator iter) {
        json val = *iter;

        if (val.is_object() && val.find("text") != val.end()) {
            text.append(val["text"].get<std::string>());
        }

        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;
}