#pragma once #include "json.hpp" #include "utils.h" #include #include class Jsonable { public: virtual nlohmann::json toJson(void) const = 0; operator nlohmann::json() const {return toJson();} }; template std::vector json2vec(const nlohmann::json& data) { using std::begin; using std::end; return std::vector(begin(data), end(data)); } template std::vector jsonList2vec(const std::string& type, const std::vector& names) { std::vector ret; for(auto name : names) { ret.push_back(utils::loadJson(type, name)); } return ret; } template std::vector> json2ptrvec(const nlohmann::json& data) { std::vector> ret; for(nlohmann::json d : data) { ret.push_back(T::create(d)); } return ret; }