Skip to content

Commit b14a148

Browse files
committed
Define serializing function for device::tasks::value_type.
This gets rid of the workaround for copying iterators.
1 parent 3b4cb17 commit b14a148

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

lib/3rd_party_adapters/nlohmann/JsonGenerator.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,17 @@ std::string toJsonString<task_tracker_systems::TaskObject>(const task_tracker_sy
3636
return jsonObject.dump(defaultJsonIndent);
3737
}
3838

39-
void to_json(nlohmann::json &jsonObject, const device::TaskCollection::const_iterator &iterator)
39+
void to_json(nlohmann::json &jsonObject, const device::TaskCollection::value_type &object)
4040
{
41-
jsonObject["id"] = iterator->first;
42-
jsonObject["label"] = iterator->second.getLabel();
43-
jsonObject["duration"] = iterator->second.getLastRecordedDuration().count();
41+
jsonObject["id"] = object.first;
42+
jsonObject["label"] = object.second.getLabel();
43+
jsonObject["duration"] = object.second.getLastRecordedDuration().count();
4444
}
4545

4646
template <>
47-
std::string toJsonString<device::TaskCollection>(const device::TaskCollection &object)
47+
std::string toJsonString<device::TaskCollection>(const device::TaskCollection &container)
4848
{
49-
std::vector<device::TaskCollection::const_iterator> itList;
50-
for (auto it = std::cbegin(object); it != std::cend(object); ++it)
51-
{
52-
itList.emplace_back(it);
53-
}
54-
nlohmann::json jsonObject(itList);
49+
nlohmann::json jsonObject(container);
5550
return jsonObject.dump(defaultJsonIndent);
5651
}
5752

0 commit comments

Comments
 (0)