Is any other numeric type other than Double not supported? #1069
-
I moved from tao json to glaze, but the move is more painful than I thought. This line confirms that no numeric type other than double is defined. Please tell me if I'm wrong, but isn't it wrong that no other value types other than double are kept? glaze/include/glaze/json/json_t.hpp Line 22 in 56755c2 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
This is similar to how many scripting languages work, where the default numeric type is a double. If it could be an integer or a double then reading in However, in most cases using |
Beta Was this translation helpful? Give feedback.
-
@stephenberry Is there a problem with integrating my own json interface? |
Beta Was this translation helpful? Give feedback.
-
The reason why your code isn't working is that by adding Thanks so much for sharing your code for your The tricky part is handling |
Beta Was this translation helpful? Give feedback.
This is similar to how many scripting languages work, where the default numeric type is a double. If it could be an integer or a double then reading in
1.0
vs1
would change the type, which would make code more complex as the developer would have to constantly callstd::visit
on numeric types because changes to the input JSON could change the type.However, in most cases using
glz::json_t
is the wrong approach to using Glaze, as it isn't strongly typed. It is usually easier (and better performing) to use C++ structs, which support explicit numeric types (likeuint16_t
,int32_t
,float
,double
, etc.).