tgbotxx  1.1.6.9
Telegram Bot C++ Library
PollOption.hpp
Go to the documentation of this file.
1 #pragma once
3 
4 namespace tgbotxx {
7  struct PollOption {
8  PollOption() = default;
9  explicit PollOption(const nl::json& json) {
10  fromJson(json);
11  }
12 
14  std::string text;
15 
17  std::int32_t voterCount{};
18 
21  nl::json toJson() const {
22  nl::json json = nl::json::object();
23  OBJECT_SERIALIZE_FIELD(json, "text", text);
24  OBJECT_SERIALIZE_FIELD(json, "voter_count", voterCount);
25  return json;
26  }
27 
29  void fromJson(const nl::json& json) {
30  OBJECT_DESERIALIZE_FIELD(json, "text", text, "", false);
31  OBJECT_DESERIALIZE_FIELD(json, "voter_count", voterCount, 0, false);
32  }
33  };
34 }
#define OBJECT_SERIALIZE_FIELD(json, json_field, field)
Available objects: https://core.telegram.org/bots/api#available-types.
Definition: Object.hpp:19
#define OBJECT_DESERIALIZE_FIELD(json, json_field, field, default_value, optional)
Deserialize.
Definition: Object.hpp:44
Definition: Api.hpp:14
This object contains information about one answer option in a poll. https://core.telegram....
Definition: PollOption.hpp:7
std::string text
Option text, 1-100 characters.
Definition: PollOption.hpp:14
std::int32_t voterCount
Number of users that voted for this option.
Definition: PollOption.hpp:17
PollOption(const nl::json &json)
Definition: PollOption.hpp:9
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Definition: PollOption.hpp:29
nl::json toJson() const
Serializes this object to JSON.
Definition: PollOption.hpp:21