diff options
author | YJBeetle <yjbeetle@gmail.com> | 2019-11-12 03:59:42 +0800 |
---|---|---|
committer | YJBeetle <yjbeetle@gmail.com> | 2019-11-12 03:59:42 +0800 |
commit | f239eef1eb7e7145bf8eddbeb7e496f266101723 (patch) | |
tree | d42d62939558ae272f65203d0a53db44c4b4ca35 /include | |
parent | 89ec4e3d1186e1a250adb18cb6a8cce7c4756bf6 (diff) |
fix #113 InlineQueryResult json parse bug
Diffstat (limited to 'include')
-rw-r--r-- | include/tgbot/TgTypeParser.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h index dbfa27e..979ba55 100644 --- a/include/tgbot/TgTypeParser.h +++ b/include/tgbot/TgTypeParser.h @@ -468,6 +468,24 @@ private: json += ','; } + template<typename T> + inline void appendToJsonNumber(std::string& json, const std::string& varName, const T& value) const { + json += '"'; + json += varName; + json += R"(":)"; + json += std::to_string(value); + json += ','; + } + inline void appendToJson(std::string &json, const std::string &varName, const int &value) const { appendToJsonNumber(json, varName, value); } + inline void appendToJson(std::string &json, const std::string &varName, const long &value) const { appendToJsonNumber(json, varName, value); } + inline void appendToJson(std::string &json, const std::string &varName, const long long &value) const { appendToJsonNumber(json, varName, value); } + inline void appendToJson(std::string &json, const std::string &varName, const unsigned &value) const { appendToJsonNumber(json, varName, value); } + inline void appendToJson(std::string &json, const std::string &varName, const unsigned long &value) const { appendToJsonNumber(json, varName, value); } + inline void appendToJson(std::string &json, const std::string &varName, const unsigned long long &value) const { appendToJsonNumber(json, varName, value); } + inline void appendToJson(std::string &json, const std::string &varName, const float &value) const { appendToJsonNumber(json, varName, value); } + inline void appendToJson(std::string &json, const std::string &varName, const double &value) const { appendToJsonNumber(json, varName, value); } + inline void appendToJson(std::string &json, const std::string &varName, const long double &value) const { appendToJsonNumber(json, varName, value); } + inline void appendToJson(std::string& json, const std::string& varName, const bool& value) const { json += '"'; json += varName; |