| 1 | #include "mtx/responses/users.hpp" |
|---|---|
| 2 | |
| 3 | #include <nlohmann/json.hpp> |
| 4 | |
| 5 | using json = nlohmann::json; |
| 6 | |
| 7 | namespace mtx { |
| 8 | namespace responses { |
| 9 | |
| 10 | void |
| 11 | from_json(const json &obj, User &user) |
| 12 | { |
| 13 | if (obj.count(key: "avatar_url") != 0 && !obj.at(key: "avatar_url").is_null()) |
| 14 | user.avatar_url = obj.at(key: "avatar_url").get<std::string>(); |
| 15 | |
| 16 | if (obj.count(key: "display_name") != 0 && !obj.at(key: "display_name").is_null()) |
| 17 | user.display_name = obj.at(key: "display_name").get<std::string>(); |
| 18 | |
| 19 | user.user_id = obj.at(key: "user_id").get<std::string>(); |
| 20 | } |
| 21 | |
| 22 | void |
| 23 | from_json(const json &obj, Users &users) |
| 24 | { |
| 25 | users.limited = obj.at(key: "limited").get<bool>(); |
| 26 | users.results = obj.at(key: "results").get<std::vector<User>>(); |
| 27 | } |
| 28 | } |
| 29 | } |
| 30 |