You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think that chaining refers wrt to nesting of the fields but another way could be to parse fields at the same level of nesting.
I maybe wrong but there's no simple exception free way to check for error without checking each field.
{"a":1, "b":2}
If I want to parse a and then b, I have to check for error twice in each step. With and_then, it's easier as you can focus on error free path and handle errors at last.
One way is to have a variable for each key and then use get() in succession but feels terse than just using and_then
Borrowing the idea of and_then from std::optional / std::expected, error handling for parsing multiple fields can be easy as it can be chained.
simdjson::ondemand::object o;
o[key1].and_then(...).and_then(...);
Instead of checking for error twice in the case above.
The text was updated successfully, but these errors were encountered: