123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- #pragma once
- #include "ResDataObject.h"
- template <typename T>
- 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);
- }
|