Repository navigation
Boolean value in array [is it possible?] #3533
|
Hi, {"jsonrpc": "1.0", "id":"curltest", "method": "importaddress", "params": ["myaddress", "testing", false] } |
Answered by
falbrechtskirchinger
Jun 13, 2022
Replies: 2 comments 5 replies
|
This is how I was doing it but the last bool vector cannot work std::tuple<std::vector<std::string>, std::vector<int>, std::vector<bool>> params;
request["params"] = nlohmann::json::array();
for (auto param : std::get<0>(parameters))
{
request["params"].push_back(param);
}
for (auto param : std::get<1>(parameters))
{
request["params"].push_back(param);
}
for (auto param : std::get<2>(parameters))
{
request["params"].push_back(param);///fails here
} |
0 replies
|
Either of the options below should work. for (bool param : std::get<2>(parameters))
{
request["params"].push_back(param);
}
for (auto param : std::get<2>(parameters))
{
request["params"].push_back(static_cast<bool>(param));
} |
5 replies
Answer selected by
kenkit
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
std::vector<bool>::referenceis not abool &as on might expect (see https://en.cppreference.com/w/cpp/container/vector_bool).Either of the options below should work.