| 1 | #include "mtx/events/tag.hpp" |
|---|---|
| 2 | |
| 3 | #include <nlohmann/json.hpp> |
| 4 | |
| 5 | using json = nlohmann::json; |
| 6 | |
| 7 | namespace mtx { |
| 8 | namespace events { |
| 9 | namespace account_data { |
| 10 | |
| 11 | void |
| 12 | from_json(const json &obj, Tag &content) |
| 13 | { |
| 14 | if (obj.contains(key: "order")) |
| 15 | content.order = obj.at(key: "order").get<double>(); |
| 16 | } |
| 17 | |
| 18 | void |
| 19 | to_json(json &obj, const Tag &content) |
| 20 | { |
| 21 | obj = nlohmann::json::object(); |
| 22 | if (content.order) |
| 23 | obj["order"] = content.order.value(); |
| 24 | } |
| 25 | |
| 26 | void |
| 27 | from_json(const json &obj, Tags &content) |
| 28 | { |
| 29 | content.tags = obj.at(key: "tags").get<std::map<std::string, Tag>>(); |
| 30 | } |
| 31 | |
| 32 | void |
| 33 | to_json(json &obj, const Tags &content) |
| 34 | { |
| 35 | obj["tags"] = content.tags; |
| 36 | } |
| 37 | |
| 38 | } // namespace state |
| 39 | } // namespace events |
| 40 | } // namespace mtx |
| 41 |