25 #include <boost/lexical_cast.hpp>
27 #include <nlohmann/json.hpp>
28 #include <type_traits>
70 std::string str = j.get<std::string>();
71 uuid =
Leosac::UUID(boost::lexical_cast<boost::uuids::uuid>(str));
73 else if (j.is_number_unsigned() && j.get<uint64_t>() == 0)
104 template <
typename T>
105 typename std::enable_if<!std::is_same<const char *, T>::value &&
106 !std::is_same<std::chrono::system_clock::time_point,
107 std::remove_reference_t<T>>::value &&
108 !std::is_enum<T>::value,
113 T ret = default_value;
116 if (!obj.at(key).is_null())
117 ret = obj.at(key).get<T>();
119 catch (
const json::out_of_range &e)
125 template <
typename T>
126 typename std::enable_if<std::is_enum<T>::value, T>::type
130 T ret = default_value;
133 if (!obj.at(key).is_null())
136 ret =
static_cast<T
>(obj.at(key).get<std::underlying_type_t<T>>());
139 catch (
const json::out_of_range &e)
145 template <
typename T>
146 typename std::enable_if<std::is_same<const char *, T>::value, std::string>::type
150 return extract_with_default<std::string>(obj, key, default_value);
157 std::chrono::system_clock::time_point
159 const std::chrono::system_clock::time_point &tp);
170 const std::string &base_key,