Reading numbers as string leads to reading error #1533
-
Hi
This leads to this error:
Am i doing something wrong here? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Thanks for your question. The Your example shows that the error code is really unhelpful, and so I've updated the code in #1535 to return a In your case, setting the What you want is to use a meta to selectively parse only the strings that you want to be numbers: template <>
struct glz::meta<my_struct>
{
using T = numbers_as_strings2;
static constexpr auto value = object("i", number<&T::i>, "d", number<&T::d>, &T::hello);
}; The meta defined above will solve your problem as long as you remove the global Is this a sufficient solution for you? |
Beta Was this translation helpful? Give feedback.
Thanks for your question. The
number
option mostly exists to facilitate theglz::number
wrapper that allows you to individually define whichstd::string
fields should be treated as number.Your example shows that the error code is really unhelpful, and so I've updated the code in #1535 to return a
parse_number_failure
if the input is not a number.In your case, setting the
.number = true
option globally tells Glaze to parse all types likestd::string
as numbers.What you want is to use a meta to selectively parse only the strings that you want to be numbers: