|
|
|
@ -18,6 +18,7 @@
|
|
|
|
|
#include "ruc/json/array.h" |
|
|
|
|
#include "ruc/json/object.h" |
|
|
|
|
#include "ruc/meta/assert.h" |
|
|
|
|
#include "ruc/meta/concepts.h" |
|
|
|
|
#include "ruc/meta/odr.h" |
|
|
|
|
|
|
|
|
|
namespace ruc::json { |
|
|
|
@ -45,36 +46,15 @@ void fromJson(const Json& json, bool& boolean)
|
|
|
|
|
boolean = json.asBool(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template<typename Json> |
|
|
|
|
void fromJson(const Json& json, int32_t& number) |
|
|
|
|
template<typename Json, Integral T> |
|
|
|
|
void fromJson(const Json& json, T& number) |
|
|
|
|
{ |
|
|
|
|
VERIFY(json.type() == Json::Type::Number); |
|
|
|
|
number = static_cast<int32_t>(json.asDouble()); |
|
|
|
|
number = static_cast<T>(json.asDouble()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template<typename Json> |
|
|
|
|
void fromJson(const Json& json, uint32_t& number) |
|
|
|
|
{ |
|
|
|
|
VERIFY(json.type() == Json::Type::Number); |
|
|
|
|
number = static_cast<uint32_t>(json.asDouble()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template<typename Json> |
|
|
|
|
void fromJson(const Json& json, int64_t& number) |
|
|
|
|
{ |
|
|
|
|
VERIFY(json.type() == Json::Type::Number); |
|
|
|
|
number = static_cast<int64_t>(json.asDouble()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template<typename Json> |
|
|
|
|
void fromJson(const Json& json, size_t& number) // uint64_t
|
|
|
|
|
{ |
|
|
|
|
VERIFY(json.type() == Json::Type::Number); |
|
|
|
|
number = static_cast<size_t>(json.asDouble()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template<typename Json> |
|
|
|
|
void fromJson(const Json& json, double& number) |
|
|
|
|
template<typename Json, FloatingPoint T> |
|
|
|
|
void fromJson(const Json& json, T& number) |
|
|
|
|
{ |
|
|
|
|
VERIFY(json.type() == Json::Type::Number); |
|
|
|
|
number = json.asDouble(); |
|
|
|
|