1 #define JWT_DISABLE_PICOJSON
2 #define JSONCONS_NO_DEPRECATED
6 #include "jsoncons/json.hpp"
14 static_assert(jsoncons::version().minor >= 167,
"A higher version of jsoncons is required!");
37 return try_emplace(key).first->value();
42 auto target = find(key);
43 if (target != end())
return target->value();
45 throw std::out_of_range(
"invalid key");
51 bool operator()(
const value_type& val,
const key_type& key)
const {
return val.key() < key; }
52 bool operator()(
const key_type& key,
const value_type& val)
const {
return key < val.key(); }
56 if (std::binary_search(this->begin(), this->end(), key, compare{}))
return 1;
69 if (val.type() == jsoncons::json_type::bool_value)
return type::boolean;
70 if (val.type() == jsoncons::json_type::int64_value)
return type::integer;
71 if (val.type() == jsoncons::json_type::uint64_value)
return type::integer;
72 if (val.type() == jsoncons::json_type::half_value)
return type::number;
73 if (val.type() == jsoncons::json_type::double_value)
return type::number;
74 if (val.type() == jsoncons::json_type::string_value)
return type::string;
75 if (val.type() == jsoncons::json_type::array_value)
return type::array;
76 if (val.type() == jsoncons::json_type::object_value)
return type::object;
78 throw std::logic_error(
"invalid type");
82 if (val.type() != jsoncons::json_type::object_value)
throw std::bad_cast();
87 if (val.type() != jsoncons::json_type::array_value)
throw std::bad_cast();
88 return val.array_value();
92 if (val.type() != jsoncons::json_type::string_value)
throw std::bad_cast();
93 return val.as_string();
98 return val.as_double();
107 if (val.type() != jsoncons::json_type::bool_value)
throw std::bad_cast();
108 return val.as_bool();
117 std::ostringstream os;
118 os << jsoncons::print(val);