yatbcpp  0.0.1
Yet another Telegram Bot CPP Library
PhotoSize_fromJson.cc
Go to the documentation of this file.
1 // From JSON Specialication //
4 #include <jsoncpp/json/json.h>
5 #include "types/telegram_type.h"
7 #include "types/PhotoSize.h"
8 
9 using namespace std;
10 
11 namespace yatbcpp {
17  template<> PhotoSize fromJson(Json::Value Data) {
18  if (!Data.isMember("file_id")) {
19  throw essential_key_missing("PhotoSize::file_id is missing");
20  }
21  if (!Data.isMember("width")) {
22  throw essential_key_missing("PhotoSize::width is missing");
23  }
24  if (!Data.isMember("height")) {
25  throw essential_key_missing("PhotoSize::height is missing");
26  }
27 
28  std::string file_id = Data["file_id"].asString();
29  std::int32_t width = Data["width"].asInt();
30  std::int32_t height = Data["height"].asInt();
31 
32  PhotoSize ret(file_id, width, height);
33 
34  if (Data.isMember("file_size")) {
35  ret.setFile_size(Data["file_size"].asInt());
36  }
37  return ret;
38  }
39 }
void setFile_size(const std::optional< std::int32_t > &file_size)
Definition: PhotoSize.cc:30
PhotoSize fromJson(Json::Value Data)
Definition: Bot.h:27