| 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(key: "waitForIframeLoad" , default_value: true); |
| 10 | create.type = obj.value(key: "type" , default_value: "" ); |
| 11 | create.url = obj.value(key: "url" , default_value: "" ); |
| 12 | create.name = obj.value(key: "name" , default_value: "" ); |
| 13 | create.id = obj.value(key: "id" , default_value: "" ); |
| 14 | create.creatorUserId = obj.value(key: "creatorUserId" , default_value: "" ); |
| 15 | create.data = obj.value(key: "data" , default_value: 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 | } |
| 33 | |