14 #ifndef JSON_SERIALIZABLE_HPP
15 #define JSON_SERIALIZABLE_HPP
17 #include <Poco/Dynamic/Var.h>
18 #include <Poco/NumberFormatter.h>
34 template <
class T =
unsigned long long>
37 T result=defaultValue;
43 result = static_cast<T>(std::stoull(var.convert<std::string>()));
51 result = static_cast<T>(var.convert<Poco::Int64>());
53 result =
static_cast<T
>(var.convert<Poco::UInt64>());
56 result =
static_cast<T
>(var.convert<
double>());
63 result = defaultValue;
71 virtual bool serialize(std::string& json)=0;
72 virtual bool unserialize(
const std::string& json)=0;
95 template <
typename T = std::
string>
98 static const size_t PRECISION=2;
103 std::istringstream(Poco::NumberFormatter::format(value, precision)) >> t;
111 #endif // JSON_SERIALIZABLE_HPP