@@ -47,6 +47,14 @@ struct JsonWrapper {
4747 }
4848 data_[std::string (key)] = *value;
4949 }
50+ template <typename T,
51+ std::enable_if_t <detail::is_vector_v<T>, bool > = true >
52+ void put (const std::string_view key, std::optional<T> value) {
53+ if (!value) {
54+ return ; // Skip empty optional
55+ }
56+ data_[std::string (key)] = TgBot::put (*value);
57+ }
5058
5159 static void merge (nlohmann::json &thiz, const nlohmann::json &other) {
5260 if (!thiz.is_object () || !other.is_object ()) {
@@ -818,7 +826,9 @@ DECLARE_PARSER_FROM_JSON(ReplyParameters) {
818826 &result->allowSendingWithoutReply );
819827 parse (data, " quote" , &result->quote );
820828 parse (data, " quote_parse_mode" , &result->quoteParseMode );
821- result->quoteEntities = parseArray<MessageEntity>(data, " quote_entities" );
829+ if (data.contains (" quote_entities" )) {
830+ result->quoteEntities = parseArray<MessageEntity>(data, " quote_entities" );
831+ }
822832 parse (data, " quote_position" , &result->quotePosition );
823833 return result;
824834}
@@ -833,7 +843,7 @@ DECLARE_PARSER_TO_JSON(ReplyParameters) {
833843 object->allowSendingWithoutReply );
834844 json.put (" quote" , object->quote );
835845 json.put (" quote_parse_mode" , object->quoteParseMode );
836- json.put (" quote_entities" , put ( object->quoteEntities ) );
846+ json.put (" quote_entities" , object->quoteEntities );
837847 json.put (" quote_position" , object->quotePosition );
838848 }
839849
0 commit comments