Use std::transform instead of for loop in json_array_to_vector.
This commit is contained in:
parent
e07dc45184
commit
d85190b113
|
@ -18,6 +18,7 @@
|
||||||
#include <iomanip> // get_time
|
#include <iomanip> // get_time
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
#include <algorithm>
|
||||||
#include "easy.hpp"
|
#include "easy.hpp"
|
||||||
#include "debug.hpp"
|
#include "debug.hpp"
|
||||||
|
|
||||||
|
@ -81,11 +82,11 @@ const std::vector<string> Easy::json_array_to_vector(const string &json)
|
||||||
|
|
||||||
if (json_array.isArray())
|
if (json_array.isArray())
|
||||||
{
|
{
|
||||||
std::vector<string> vec;
|
// Transform array of Json::Value to vector of string.
|
||||||
for (const Json::Value &value : json_array)
|
std::vector<string> vec(json_array.size());
|
||||||
{
|
std::transform(json_array.begin(), json_array.end(), vec.begin(),
|
||||||
vec.push_back(value.toStyledString());
|
[](const Json::Value &j)
|
||||||
}
|
{ return j.toStyledString(); });
|
||||||
return vec;
|
return vec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue