Go to the documentation of this file. 1 #ifndef JWT_CPP_NLOHMANN_JSON_TRAITS_H
2 #define JWT_CPP_NLOHMANN_JSON_TRAITS_H
5 #include "nlohmann/json.hpp"
31 throw std::logic_error(
"invalid type");
41 return val.
get<std::string>();
53 default:
throw std::bad_cast();
59 return val.
get<
bool>();
64 return val.
get<
double>();
static json::object_t as_object(const json &val)
Definition: traits.h:34
static bool as_bool(const json &val)
Definition: traits.h:57
json::object_t object_type
Definition: traits.h:12
json::array_t array_type
Definition: traits.h:13
static int64_t as_int(const json &val)
Definition: traits.h:49
basic_json<> json
default JSON class
Definition: json.hpp:3472
@ object
object (unordered set of name/value pairs)
static double as_number(const json &val)
Definition: traits.h:62
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
Definition: json.hpp:19972
@ number_float
number value (floating-point)
@ number_integer
number value (signed integer)
ArrayType< basic_json, AllocatorType< basic_json > > array_t
a type for an array
Definition: json.hpp:18061
static std::string as_string(const json &val)
Definition: traits.h:39
NumberIntegerType number_integer_t
a type for a number (integer)
Definition: json.hpp:18212
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json parse(InputType &&i, const parser_callback_t cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
deserialize from a compatible input
Definition: json.hpp:24398
static jwt::json::type get_type(const json &val)
Definition: traits.h:19
static bool parse(json &val, std::string str)
Definition: traits.h:67
nlohmann::json json
Definition: traits.h:10
std::string string_type
Definition: traits.h:14
JSON Web Token.
Definition: base.h:20
value::object object
Definition: picojson.h:210
ObjectType< StringType, basic_json, object_comparator_t, AllocatorType< std::pair< const StringType, basic_json > >> object_t
a type for an object
Definition: json.hpp:18015
@ number_unsigned
number value (unsigned integer)
type
Generic JSON types used in JWTs.
Definition: jwt.h:1794
@ array
array (ordered collection of values)
BooleanType boolean_t
a type for a boolean
Definition: json.hpp:18140
json::number_integer_t integer_type
Definition: traits.h:16
string_t dump(const int indent=-1, const char indent_char=' ', const bool ensure_ascii=false, const error_handler_t error_handler=error_handler_t::strict) const
serialization
Definition: json.hpp:19919
a class to store JSON values
Definition: json.hpp:3448
json::number_float_t number_type
Definition: traits.h:15
value::array array
Definition: picojson.h:209
NumberFloatType number_float_t
a type for a number (floating-point)
Definition: json.hpp:18351
static std::string serialize(const json &val)
Definition: traits.h:72
static json::array_t as_array(const json &val)
Definition: traits.h:44
json::boolean_t boolean_type
Definition: traits.h:17
auto get() const noexcept(noexcept(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))) -> decltype(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 >
get a (pointer) value (explicit)
Definition: json.hpp:20708