| 1 | #include "mtx/events/widget.hpp" |
| 2 | |
| 3 | #include <nlohmann/json.hpp> |
| 4 | |
| 5 | namespace mtx::events::state { |
| 6 | void |
| 7 | from_json(const nlohmann::json &obj, Widget &create) |
| 8 | { |
| 9 | create.waitForIframeLoad = obj.value("waitForIframeLoad", true); |
| 10 | create.type = obj.value("type", ""); |
| 11 | create.url = obj.value("url", ""); |
| 12 | create.name = obj.value("name", ""); |
| 13 | create.id = obj.value("id", ""); |
| 14 | create.creatorUserId = obj.value("creatorUserId", ""); |
| 15 | create.data = obj.value("data", std::map<std::string, std::string>{}); |
| 16 | } |
| 17 | |
| 18 | void |
| 19 | to_json(nlohmann::json &obj, const Widget &create) |
| 20 | { |
| 21 | if (!create.name.empty()) |
| 22 | obj["name"] = create.name; |
| 23 | if (!create.data.empty()) |
| 24 | obj["data"] = create.data; |
| 25 | |
| 26 | obj["type"] = create.type; |
| 27 | obj["url"] = create.url; |
| 28 | obj["id"] = create.id; |
| 29 | obj["creatorUserId"] = create.creatorUserId; |
| 30 | obj["waitForIframeLoad"] = create.waitForIframeLoad; |
| 31 | } |
| 32 | } |