#pragma once #include "json.h" struct Identity{ template T operator()(T t) const { return t; } }; struct All{ template bool operator()(T const & t) const { return true; } }; template inline js::Value vector_to_json(C const & container, F1 const & transform = Identity(), F2 const & filter = All()){ js::Array array; for(auto x : container){ if(!filter(x)) continue; array.push_back(to_json(transform(x))); } return array; }