135 {
136 try {
137 std::stringstream ss(
json);
138 pt::ptree root;
139 pt::read_json(ss, root);
140
141 for (
int i = 0; i <
subtasks.size(); i++) {
143 }
145 if (root.get_child_optional("subtasks")!= boost::none) {
146 pt::ptree subtask_list = root.get_child("subtasks");
147 for (auto subtask = subtask_list.begin(); subtask != subtask_list.end(); ++subtask) {
148 BBLSubTask* new_subtask = new BBLSubTask(this);
149
150 boost::optional<std::string> subtask_id = subtask->second.get_optional<std::string>("id");
151 if (subtask_id.has_value()) new_subtask->task_id = subtask_id.value();
152
153 boost::optional<std::string> subtask_name = subtask->second.get_optional<std::string>("name");
154 if (subtask_name.has_value()) new_subtask->task_name = subtask_name.value();
155
156 boost::optional<std::string> subtask_create_time = subtask->second.get_optional<std::string>("create_time");
157 if (subtask_create_time.has_value()) new_subtask->task_create_time = subtask_create_time.value();
158
159 boost::optional<std::string> subtask_plate_idx = subtask->second.get_optional<std::string>("plate_idx");
160 if (subtask_plate_idx.has_value()) new_subtask->task_partplate_idx = subtask_plate_idx.value();
161
162 boost::optional<std::string> subtask_printer = subtask->second.get_optional<std::string>("printer");
163 if (subtask_printer.has_value()) new_subtask->task_printer_dev_id = subtask_printer.value();
164
165 boost::optional<std::string> subtask_weight = subtask->second.get_optional<std::string>("weight");
166 if (subtask_weight.has_value()) new_subtask->task_weight = subtask_weight.value();
168 }
169 }
170 }
171 catch (...) {
172 BOOST_LOG_TRIVIAL(
trace) <<
"parse_content_json failed! json=" <<
json;
173 }
174 return 0;
175 }
std::vector< BBLSubTask * > subtasks
Definition ProjectTask.hpp:269
void trace(unsigned int level, const char *message)
Definition utils.cpp:247
nlohmann::json json
Definition AssembleList.cpp:42