nullable_t fails for containers with null values
Closed this issue · 6 comments
omartijn commented
#include <json_dto/pub.hpp>
#include <string>
#include <vector>
struct nullable {
std::vector<json_dto::nullable_t<std::string>> strings;
template <typename io_type>
void json_io(io_type& io) {
io& json_dto::optional_no_default("strings", strings);
}
};
int main() {
std::string serialized1{R"({"strings":[null]})"};
json_dto::from_json<nullable>(serialized1);
}
Unless I'm mistaken, this should work. The values inside the vector are nullable, so it should be allowed to deserialize a JSON null. It fails with an exception, though.
eao197 commented
Hi! Thanks for reporting. I'll take a look at it.
eao197 commented
Could you check the latest commit from issue-20-v1
branch? I hope it fixes the problem.
omartijn commented
Yes! I can confirm that the problem is fixed on that branch. 👍
eao197 commented
Great!
eao197 commented
I've fixed v.0.3.2 with the resolution of this issue.
omartijn commented
Perfect! Thank you.