-
Notifications
You must be signed in to change notification settings - Fork 221
Home
Kim edited this page Mar 12, 2018
·
4 revisions
- https://github.com/eluck/picojson/tree/master/examples
- please add yours here!
template<typename T>
picojson::value toJson(const std::deque<T>& items)
{
picojson::array arr;
for(const auto& i: items)
{
arr.push_back(picojson::value>(i));
}
return picojson::value(arr);
}
template<typename T>
std::deque<T>& fromJson(std::deque<T>& items, const picojson::value& input)
{
if(input.is<picojson::array>())
{
const auto& array = input.get<picojson::array>();
for(const auto a: array)
{
items.push_back(a.get<T>());
}
}
return items;
}