tgbotxx 1.1.6.9
Telegram Bot C++ Library
Loading...
Searching...
No Matches
PollOption.hpp
Go to the documentation of this file.
1#pragma once
3
4namespace 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
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.
std::int32_t voterCount
Number of users that voted for this option.
PollOption(const nl::json &json)
Definition PollOption.hpp:9
void fromJson(const nl::json &json)
Deserializes this object from JSON.
nl::json toJson() const
Serializes this object to JSON.