-
Notifications
You must be signed in to change notification settings - Fork 221
Home
Mvb1122 edited this page Sep 3, 2021
·
4 revisions
- https://github.com/eluck/picojson/tree/master/examples
- https://replit.com/@mb1122/Requesting-and-Parsing-HTTP-Requests-in-C?v=1
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;
}