#pragma once #include "ResDataObject.h" template static inline T JSONTo (const std::string& in) { static_assert (false, "bad type for JSONTo"); } template <> static inline float JSONTo (const std::string& in) { ResDataObject json; json.decode (in.c_str ()); auto value = atof (((string) json [0]).c_str ()); return (float) value; } template <> static inline double JSONTo (const std::string& in) { ResDataObject json; json.decode (in.c_str ()); auto value = atof (((string) json [0]).c_str ()); return value; } template <> static inline int JSONTo (const std::string& in) { ResDataObject json; json.decode (in.c_str ()); auto value = atoi (((string) json [0]).c_str ()); return value; } static inline std::string ToJSON (int value) { return std::to_string (value); } static inline std::string ToJSON (float value) { return std::to_string (value); }