23 #ifndef _LIBS_WEBVIEW_REST_ARRAY_H_
24 #define _LIBS_WEBVIEW_REST_ARRAY_H_
26 #include <boost/property_tree/json_parser.hpp>
27 #include <boost/property_tree/ptree.hpp>
61 to_json(
bool pretty =
false)
const
63 std::string rv =
"[\n";
64 for (
size_t i = 0; i < items_.size(); ++i) {
65 rv += items_[i].to_json(pretty);
66 if (i < items_.size() - 1) {
82 std::stringstream ss(json);
83 boost::property_tree::ptree pt;
84 boost::property_tree::read_json(ss, pt);
85 for (
auto &c : pt.get_child(
"")) {
87 boost::property_tree::write_json(os, c.second);
89 m.from_json(os.str());
90 items_.push_back(std::move(m));
105 for (
const auto &i : items_) {
134 items_.push_back(std::move(m));
138 std::vector<M> items_;