Skip to content

Is any other numeric type other than Double not supported? #1069

Answered by stephenberry
meftunca asked this question in Q&A
Discussion options

You must be logged in to vote

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 vs 1 would change the type, which would make code more complex as the developer would have to constantly call std::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 (like uint16_t, int32_t, float, double, etc.).

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by meftunca
Comment options

You must be logged in to vote
3 replies
@stephenberry
Comment options

@meftunca
Comment options

@meftunca
Comment options

Comment options

You must be logged in to vote
2 replies
@meftunca
Comment options

@stephenberry
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants