Expanding the quoted_t to arrays/nested arrays #261
-
If instead our buffer was something like: std::string buffer = R"({"x":["999.2", "1015.2"]})"; Is there a good way to leverage quoted_t to parse these directly to doubles? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
This is a great question. Because it would be best to parse these directly into something like |
Beta Was this translation helpful? Give feedback.
-
@raddy, support has been added with #263 You can now register higher level objects and arrays and the underlying values will be quoted. For your use case, see how the struct A
{
double x;
std::vector<uint32_t> y;
};
template <>
struct glz::meta<A>
{
static constexpr auto value = object("x", glz::quoted<&A::x>(), "y", glz::quoted<&A::y>());
}; |
Beta Was this translation helpful? Give feedback.
-
This is quite sick! Even this case works May want to add the nested example to your tests (since it is pretty common to stumble into as well!) |
Beta Was this translation helpful? Give feedback.
-
Yeah, we'll have to make more test cases, but this should even work when values are in objects as well. |
Beta Was this translation helpful? Give feedback.
@raddy, support has been added with #263
You can now register higher level objects and arrays and the underlying values will be quoted.
For your use case, see how the
std::vector
is registered: