19 #ifndef IRCCD_JSON_UTIL_HPP
20 #define IRCCD_JSON_UTIL_HPP
76 static auto get(
const nlohmann::json& value) noexcept -> std::optional<bool>;
90 static auto get(
const nlohmann::json& value) noexcept -> std::optional<double>;
104 static auto get(
const nlohmann::json& value) -> std::optional<std::string>;
118 static auto get(
const nlohmann::json& value) -> std::optional<std::int8_t>;
132 static auto get(
const nlohmann::json& value) -> std::optional<std::int16_t>;
146 static auto get(
const nlohmann::json& value) -> std::optional<std::int32_t>;
160 static auto get(
const nlohmann::json& value) noexcept -> std::optional<std::int64_t>;
174 static auto get(
const nlohmann::json& value) -> std::optional<std::uint8_t>;
188 static auto get(
const nlohmann::json& value) -> std::optional<std::uint16_t>;
202 static auto get(
const nlohmann::json& value) -> std::optional<std::uint32_t>;
216 static auto get(
const nlohmann::json& value) noexcept -> std::optional<std::uint64_t>;
240 template <
typename Type>
241 auto get(
const std::string& key)
const noexcept -> std::optional<Type>
243 const auto it = find(key);
261 template <
typename Type,
typename DefaultValue>
262 auto optional(
const std::string& key, DefaultValue&& def)
const noexcept -> std::optional<Type>
264 const auto it = find(key);
267 return std::optional<Type>(std::forward<DefaultValue>(def));
281 auto pretty(
const nlohmann::json& value,
int indent = 4) -> std::string;
290 auto contains(
const nlohmann::json& array,
const nlohmann::json& value) noexcept -> bool;
Convenient JSON object parser.
Definition: json_util.hpp:225
auto optional(const std::string &key, DefaultValue &&def) const noexcept -> std::optional< Type >
Definition: json_util.hpp:262
deserializer(const nlohmann::json &obj)
auto get(const std::string &key) const noexcept -> std::optional< Type >
Definition: json_util.hpp:241
auto contains(const nlohmann::json &array, const nlohmann::json &value) noexcept -> bool
auto pretty(const nlohmann::json &value, int indent=4) -> std::string
Parent namespace.
Definition: acceptor.hpp:43
static auto get(const nlohmann::json &value) noexcept -> std::optional< bool >
static auto get(const nlohmann::json &value) noexcept -> std::optional< double >
static auto get(const nlohmann::json &value) -> std::optional< std::int16_t >
static auto get(const nlohmann::json &value) -> std::optional< std::int32_t >
static auto get(const nlohmann::json &value) noexcept -> std::optional< std::int64_t >
static auto get(const nlohmann::json &value) -> std::optional< std::int8_t >
static auto get(const nlohmann::json &value) -> std::optional< std::string >
static auto get(const nlohmann::json &value) -> std::optional< std::uint16_t >
static auto get(const nlohmann::json &value) -> std::optional< std::uint32_t >
static auto get(const nlohmann::json &value) noexcept -> std::optional< std::uint64_t >
static auto get(const nlohmann::json &value) -> std::optional< std::uint8_t >
Describe how to convert a JSON value.
Definition: json_util.hpp:63