yatbcpp  0.0.1
Yet another Telegram Bot CPP Library
Location_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/Location.h"
8 
9 namespace yatbcpp {
15  template<> Location fromJson(Json::Value Data) {
16  if (!Data.isMember("longitude")) {
17  throw essential_key_missing("Location::longitude is missing");
18  }
19  if (!Data.isMember("latitude")) {
20  throw essential_key_missing("Location::latitude is missing");
21  }
22 
23  float longitude = Data["longitude"].asFloat();
24  float latitude = Data["latitude"].asFloat();
25 
26  Location ret(longitude, latitude);
27 
28  return ret;
29  }
30 }
T fromJson(Json::Value Data)
Definition: Bot.h:27