We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is this possible to get a value with auto data type detection?
Consider following:
struct Test { std::string value; int32_t index; std::vector<int32_t> acro; }
To parse these, we need to do the following:
void from_json(const json& j, Files::Chapters::Test& p) { p.value = j.at("value").get<std::string>(); p.index = j.at("index").get<int32_t>(); p.acro = j.at("acro").get<std::vector<int32_t>>(); }
Thats quite a boilerplate.
We can also do this:
void from_json(const json& j, Files::Chapters::Test& p) { p.value = j.at("value").get<typeof(p.value)>(); p.index = j.at("index").get<typeof(p.index)>(); p.acro = j.at("acro").get<typeof(p.acro)>(); }
As you can see, this is repetitive thus redudant. Can't we simply get value with the data type of a object we assign to?
The text was updated successfully, but these errors were encountered:
You can at least do this:
void from_json(const json& j, Test& p) { p.value = j.at("value"); p.index = j.at("index"); p.acro = j.at("acro").get<std::vector<int32_t>>(); }
For the vector, there seems to be confusion. Are the first two lines what you want?
Sorry, something went wrong.
Yep, good for common data types.
Thanks 👍
No branches or pull requests
Is this possible to get a value with auto data type detection?
Consider following:
To parse these, we need to do the following:
Thats quite a boilerplate.
We can also do this:
As you can see, this is repetitive thus redudant. Can't we simply get value with the data type of a object we assign to?
The text was updated successfully, but these errors were encountered: