From 64174491dac84c559db5c48ed850177fa3eb4da0 Mon Sep 17 00:00:00 2001 From: jellybrick Date: Sat, 14 Mar 2020 23:21:30 +0900 Subject: Fix #127, #128 & Code quality improvements It seems that the author of this code misunderstood 'Array of PollOption' as 'PollOption'. --- src/TgTypeParser.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/TgTypeParser.cpp') 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()); result->id = data.get("id", 0); result->question = data.get("question", ""); - result->options = tryParseJson(&TgTypeParser::parseJsonAndGetPollOption, data, "options"); - result->is_closed = data.get("is_closed"); + result->options = parseJsonAndGetArray(&TgTypeParser::parseJsonAndGetPollOption, data, "options"); + result->isClosed = data.get("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()); 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; -- cgit v1.2.3