summaryrefslogtreecommitdiff
path: root/src/TgTypeParser.cpp
diff options
context:
space:
mode:
authorjellybrick <shlee1503@naver.com>2020-03-14 23:21:30 +0900
committerjellybrick <shlee1503@naver.com>2020-03-14 23:21:42 +0900
commit64174491dac84c559db5c48ed850177fa3eb4da0 (patch)
tree5f7a754d57c2a7ec439f309df5e4b8d964d0834f /src/TgTypeParser.cpp
parent19f49b7a2f540a756ed9759b0fa5fb52bf73f20e (diff)
Fix #127, #128 & Code quality improvements
It seems that the author of this code misunderstood 'Array of PollOption' as 'PollOption'.
Diffstat (limited to 'src/TgTypeParser.cpp')
-rw-r--r--src/TgTypeParser.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp
index e002c60..4d91d28 100644
--- a/src/TgTypeParser.cpp
+++ b/src/TgTypeParser.cpp
@@ -377,8 +377,8 @@ Poll::Ptr TgTypeParser::parseJsonAndGetPoll(const ptree& data) const {
auto result(make_shared<Poll>());
result->id = data.get("id", 0);
result->question = data.get("question", "");
- result->options = tryParseJson<PollOption>(&TgTypeParser::parseJsonAndGetPollOption, data, "options");
- result->is_closed = data.get<bool>("is_closed");
+ result->options = parseJsonAndGetArray<PollOption>(&TgTypeParser::parseJsonAndGetPollOption, data, "options");
+ result->isClosed = data.get<bool>("is_closed");
return result;
}
@@ -390,8 +390,8 @@ string TgTypeParser::parsePoll(const Poll::Ptr& object) const {
result += '{';
appendToJson(result, "id", object->id);
appendToJson(result, "question", object->question);
- appendToJson(result, "options", parsePollOption(object->options));
- appendToJson(result, "is_closed", object->is_closed);
+ appendToJson(result, "options", parseArray(&TgTypeParser::parsePollOption, object->options));
+ appendToJson(result, "is_closed", object->isClosed);
removeLastComma(result);
result += '}';
return result;
@@ -400,7 +400,7 @@ string TgTypeParser::parsePoll(const Poll::Ptr& object) const {
PollOption::Ptr TgTypeParser::parseJsonAndGetPollOption(const ptree& data) const {
auto result(make_shared<PollOption>());
result->text = data.get("text", "");
- result->voter_count = data.get("voter_count", 0);
+ result->voterCount = data.get("voter_count", 0);
return result;
}
@@ -411,7 +411,7 @@ string TgTypeParser::parsePollOption(const PollOption::Ptr& object) const {
string result;
result += '{';
appendToJson(result, "text", object->text);
- appendToJson(result, "voter_count", object->voter_count);
+ appendToJson(result, "voter_count", object->voterCount);
removeLastComma(result);
result += '}';
return result;