zxs 13 godzin temu
rodzic
commit
a3c20e54e3
2 zmienionych plików z 372 dodań i 397 usunięć
  1. 371 396
      robot/robotics/json.hpp
  2. 1 1
      robot/robotics/v2/nexus_net_client.hpp

+ 371 - 396
robot/robotics/json.hpp

@@ -14,431 +14,422 @@
 #include <nlohmann/json.hpp>
 //rttr
 #include <rttr/registration>
-//robotics
-#include "utils.hpp"
 
 namespace robotics {
 	namespace v3 {
-		template <typename, template <typename...> class>
-		struct is_specialization : std::false_type {};
-		template <template <typename...> class Template, typename... Args>
-		struct is_specialization<Template<Args...>, Template> : std::true_type {};
-		class json_convert;
-		class json_convert_impl {
-			friend class json_convert;
-			static void serialize(rttr::instance const& value, nlohmann::json& result) {
-				rttr::instance obj = value.get_type().get_raw_type().is_wrapper() ? value.get_wrapped_instance() : value;
-				auto properties = obj.get_derived_type().get_properties();
-				for (auto& property : properties) {
-					std::string prop_name;
-					rttr::variant no_json = property.get_metadata("NoJson");
-					rttr::variant prop_var_name = property.get_metadata("Json");
-					if (no_json.get_type() == rttr::type::get<bool>() && no_json.get_value<bool>()) {
-						continue;
-					}
-					if (prop_var_name.get_type() == rttr::type::get<std::string>()) {
-						prop_name = prop_var_name.get_value<std::string>();
-					}
-					else {
-						prop_name = std::string(property.get_name());
-					}
-					if (utils::rttr_type<int>(property.get_type())) {
-						result[prop_name] = property.get_value(obj).get_value<int>();
-					}
-					else if (utils::rttr_type<bool>(property.get_type())) {
-						result[prop_name] = property.get_value(obj).get_value<bool>();
-					}
-					else if (utils::rttr_type<double>(property.get_type())) {
-						result[prop_name] = property.get_value(obj).get_value<double>();
-					}
-					else if (utils::rttr_type<float>(property.get_type())) {
-						result[prop_name] = property.get_value(obj).get_value<float>();
-					}
-					else if (utils::rttr_type<std::int64_t>(property.get_type())) {
-						result[prop_name] = property.get_value(obj).get_value<std::int64_t>();
-					}
-					else if (utils::rttr_type<datetime>(property.get_type())) {
-						result[prop_name] = property.get_value(obj).get_value<datetime>().to_string();
-					}
-					else if (utils::rttr_type<std::string>(property.get_type())) {
-						result[prop_name] = property.get_value(obj).get_value<std::string>();
-					}
-					//list
-					else if (utils::rttr_type<std::vector<int>>(property.get_type())) {
-						result[prop_name] = property.get_value(obj).get_value<std::vector<int>>();
-					}
-					else if (utils::rttr_type<std::vector<bool>>(property.get_type())) {
-						result[prop_name] = property.get_value(obj).get_value<std::vector<bool>>();
-					}
-					else if (utils::rttr_type<std::vector<double>>(property.get_type())) {
-						result[prop_name] = property.get_value(obj).get_value<std::vector<double>>();
-					}
-					else if (utils::rttr_type<std::vector<float>>(property.get_type())) {
-						result[prop_name] = property.get_value(obj).get_value<std::vector<float>>();
-					}
-					else if (utils::rttr_type<std::vector<std::int64_t>>(property.get_type())) {
-						result[prop_name] = property.get_value(obj).get_value<std::vector<std::int64_t>>();
-					}
-					else if (utils::rttr_type<std::vector<std::string>>(property.get_type())) {
-						result[prop_name] = property.get_value(obj).get_value<std::vector<std::string>>();
-					}
-					else if (utils::rttr_type<std::vector<datetime>>(property.get_type())) {
-						std::vector<std::string> datetime_list;
-						auto times = property.get_value(obj).get_value<std::vector<datetime>>();
-						for (auto& it : times) {
-							datetime_list.push_back(it.to_string());
-						}
-						result[prop_name] = datetime_list;
-					}
-					//嵌套结构体列表
-					else if (property.get_type().is_sequential_container()) {
-						result[prop_name] = nlohmann::json::array();
-						auto value_tmp = property.get_value(obj);
-						for (auto& it : value_tmp.create_sequential_view()) {
-							nlohmann::json child;
-							serialize(it.extract_wrapped_value(), child);
-							result[prop_name].push_back(child);
-						}
-					}
-					//嵌套结构体
-					else if (property.get_type().is_class()) {
-						auto value_tmp = property.get_value(obj);
-						serialize(value_tmp, result[prop_name]);
+		class json_convert {
+		public:
+			/**
+			 * @brief 序列化
+			 * @param value
+			 * @param result
+			 */
+			static void serialize(rttr::variant const& value, nlohmann::json& result) {
+				if (value.get_type().is_sequential_container()) {
+					result = nlohmann::json::array();
+					for (auto& it : value.create_sequential_view()) {
+						nlohmann::json child;
+						serialize(it.extract_wrapped_value(), child);
+						result.push_back(child);
 					}
 				}
-			}
-			static void deserialize(nlohmann::json const& value, rttr::instance result) {
-				auto properties = result.get_derived_type().get_properties();
-				for (auto& property : properties) {
-					std::string prop_name;
-					rttr::variant no_json = property.get_metadata("NoJson");
-					rttr::variant prop_var_name = property.get_metadata("Json");
-					if (no_json.get_type() == rttr::type::get<bool>() && no_json.get_value<bool>())
-						continue;
-					if (prop_var_name.get_type() == rttr::type::get<std::string>())
-						prop_name = prop_var_name.get_value<std::string>();
-					else
-						prop_name = std::string(property.get_name());
-					if (!value.contains(prop_name))
-						continue;
-
-					if (utils::rttr_type<int>(property.get_type())) {
-						int value_tmp = 0;
-						if (value[prop_name].type() == nlohmann::json::value_t::number_integer ||
-							value[prop_name].type() == nlohmann::json::value_t::number_unsigned) {
-							value_tmp = value[prop_name].get<int>();
-						}
-						else if (value[prop_name].type() == nlohmann::json::value_t::boolean) {
-							value_tmp = value[prop_name].get<bool>() ? 1 : 0;
-						}
-						else if (value[prop_name].type() == nlohmann::json::value_t::number_float) {
-							value_tmp = int(value[prop_name].get<float>());
-						}
-						else if (value[prop_name].type() == nlohmann::json::value_t::string) {
-							value_tmp = std::atoi(value[prop_name].get<std::string>().c_str());
+				else {
+					auto properties = value.get_type().get_properties();
+					for (auto& property : properties) {
+						std::string prop_name;
+						rttr::variant no_json = property.get_metadata("NoJson");
+						rttr::variant prop_var_name = property.get_metadata("Json");
+						if (no_json.is_type<bool>() && no_json.get_value<bool>()) {
+							continue;
 						}
-						property.set_value(result, value_tmp);
-					}
-					else if (utils::rttr_type<bool>(property.get_type())) {
-						bool value_tmp = false;
-						if (value[prop_name].type() == nlohmann::json::value_t::number_integer ||
-							value[prop_name].type() == nlohmann::json::value_t::number_unsigned) {
-							value_tmp = value[prop_name].get<int>() > 1;
+						if (prop_var_name.is_type<std::string>()) {
+							prop_name = prop_var_name.get_value<std::string>();
 						}
-						else if (value[prop_name].type() == nlohmann::json::value_t::boolean) {
-							value_tmp = value[prop_name].get<bool>();
+						else {
+							prop_name = std::string(property.get_name());
 						}
-						else if (value[prop_name].type() == nlohmann::json::value_t::number_float) {
-							value_tmp = value[prop_name].get<float>() > 1;
+						if (rttr::type::get<int>() == property.get_type()) {
+							result[prop_name] = property.get_value(value).get_value<int>();
 						}
-						else if (value[prop_name].type() == nlohmann::json::value_t::string) {
-							value_tmp = value[prop_name].get<std::string>() == "true" || value[prop_name].get<std::string>() == "True" || value[prop_name].get<std::string>() == "TRUE" || value[prop_name].get<std::string>() == "1";
+						else if (rttr::type::get<bool>() == property.get_type()) {
+							result[prop_name] = property.get_value(value).get_value<bool>();
 						}
-						property.set_value(result, value_tmp);
-					}
-					else if (utils::rttr_type<double>(property.get_type())) {
-						double value_tmp = 0;
-						if (value[prop_name].type() == nlohmann::json::value_t::number_integer ||
-							value[prop_name].type() == nlohmann::json::value_t::number_unsigned) {
-							value_tmp = value[prop_name].get<int>();
+						else if (rttr::type::get<double>() == property.get_type()) {
+							result[prop_name] = property.get_value(value).get_value<double>();
 						}
-						else if (value[prop_name].type() == nlohmann::json::value_t::boolean) {
-							value_tmp = value[prop_name].get<bool>() ? 1 : 0;
+						else if (rttr::type::get<float>() == property.get_type()) {
+							result[prop_name] = property.get_value(value).get_value<float>();
 						}
-						else if (value[prop_name].type() == nlohmann::json::value_t::number_float) {
-							value_tmp = value[prop_name].get<float>();
+						else if (rttr::type::get<std::int64_t>() == property.get_type()) {
+							result[prop_name] = property.get_value(value).get_value<std::int64_t>();
 						}
-						else if (value[prop_name].type() == nlohmann::json::value_t::string) {
-							value_tmp = std::atof(value[prop_name].get<std::string>().c_str());
+						else if (rttr::type::get<v3::datetime>() == property.get_type()) {
+							result[prop_name] = property.get_value(value).get_value<v3::datetime>().to_string();
 						}
-						property.set_value(result, value_tmp);
-					}
-					else if (utils::rttr_type<float>(property.get_type())) {
-						float value_tmp = 0;
-						if (value[prop_name].type() == nlohmann::json::value_t::number_integer ||
-							value[prop_name].type() == nlohmann::json::value_t::number_unsigned) {
-							value_tmp = value[prop_name].get<int>();
+						else if (rttr::type::get<std::string>() == property.get_type()) {
+							result[prop_name] = property.get_value(value).get_value<std::string>();
 						}
-						else if (value[prop_name].type() == nlohmann::json::value_t::boolean) {
-							value_tmp = value[prop_name].get<bool>() ? 1 : 0;
+						//list
+						else if (rttr::type::get<std::vector<int>>() == property.get_type()) {
+							result[prop_name] = property.get_value(value).get_value<std::vector<int>>();
 						}
-						else if (value[prop_name].type() == nlohmann::json::value_t::number_float) {
-							value_tmp = value[prop_name].get<float>();
+						else if (rttr::type::get<std::vector<bool>>() == property.get_type()) {
+							result[prop_name] = property.get_value(value).get_value<std::vector<bool>>();
 						}
-						else if (value[prop_name].type() == nlohmann::json::value_t::string) {
-							value_tmp = std::atof(value[prop_name].get<std::string>().c_str());
+						else if (rttr::type::get<std::vector<double>>() == property.get_type()) {
+							result[prop_name] = property.get_value(value).get_value<std::vector<double>>();
 						}
-						property.set_value(result, value_tmp);
-					}
-					else if (utils::rttr_type<std::int64_t>(property.get_type())) {
-						std::int64_t value_tmp = 0;
-						if (value[prop_name].type() == nlohmann::json::value_t::number_integer ||
-							value[prop_name].type() == nlohmann::json::value_t::number_unsigned) {
-							value_tmp = value[prop_name].get<std::int64_t>();
+						else if (rttr::type::get<std::vector<float>>() == property.get_type()) {
+							result[prop_name] = property.get_value(value).get_value<std::vector<float>>();
 						}
-						else if (value[prop_name].type() == nlohmann::json::value_t::boolean) {
-							value_tmp = value[prop_name].get<bool>() ? 1 : 0;
+						else if (rttr::type::get<std::vector<std::int64_t>>() == property.get_type()) {
+							result[prop_name] = property.get_value(value).get_value<std::vector<std::int64_t>>();
 						}
-						else if (value[prop_name].type() == nlohmann::json::value_t::number_float) {
-							value_tmp = std::int64_t(value[prop_name].get<float>());
+						else if (rttr::type::get<int>() == property.get_type()) {
+							result[prop_name] = property.get_value(value).get_value<std::vector<std::string>>();
 						}
-						else if (value[prop_name].type() == nlohmann::json::value_t::string) {
-							value_tmp = std::atoll(value[prop_name].get<std::string>().c_str());
-						}
-						property.set_value(result, value_tmp);
-					}
-					else if (utils::rttr_type<datetime>(property.get_type())) {
-						datetime value_tmp;
-						if (value[prop_name].type() == nlohmann::json::value_t::number_integer ||
-							value[prop_name].type() == nlohmann::json::value_t::number_unsigned) {
-							value_tmp = (time_t)value[prop_name].get<std::int64_t>();
-						}
-						else if (value[prop_name].type() == nlohmann::json::value_t::number_float) {
-							value_tmp = time_t(value[prop_name].get<float>());
+						else if (rttr::type::get<std::vector<v3::datetime>>() == property.get_type()) {
+							std::vector<std::string> datetime_list;
+							auto times = property.get_value(value).get_value<std::vector<v3::datetime>>();
+							for (auto& it : times) {
+								datetime_list.push_back(it.to_string());
+							}
+							result[prop_name] = datetime_list;
+						}
+						//嵌套结构体列表
+						else if (property.get_type().is_sequential_container()) {
+							result[prop_name] = nlohmann::json::array();
+							auto value_tmp = property.get_value(value);
+							for (auto& it : value_tmp.create_sequential_view()) {
+								nlohmann::json child;
+								serialize(it.extract_wrapped_value(), child);
+								result[prop_name].push_back(child);
+							}
 						}
-						else if (value[prop_name].type() == nlohmann::json::value_t::string) {
-							value_tmp = value[prop_name].get<std::string>();
+						//嵌套结构体
+						else if (property.get_type().is_class()) {
+							auto value_tmp = property.get_value(value);
+							serialize(value_tmp, result[prop_name]);
 						}
-						property.set_value(result, value_tmp);
 					}
-					else if (utils::rttr_type<std::string>(property.get_type())) {
-						std::string value_tmp;
-						if (value[prop_name].type() == nlohmann::json::value_t::number_integer ||
-							value[prop_name].type() == nlohmann::json::value_t::number_unsigned) {
-							value_tmp = std::to_string(value[prop_name].get<std::int64_t>());
-						}
-						else if (value[prop_name].type() == nlohmann::json::value_t::boolean) {
-							value_tmp = value[prop_name].get<bool>() ? "true" : "false";
-						}
-						else if (value[prop_name].type() == nlohmann::json::value_t::number_float) {
-							value_tmp = std::to_string(value[prop_name].get<float>());
-						}
-						else if (value[prop_name].type() == nlohmann::json::value_t::string) {
-							value_tmp = value[prop_name].get<std::string>();
-						}
-						property.set_value(result, value_tmp);
+				}
+			}
+			/**
+			 * @brief 反序列化
+			 * @param value
+			 * @param result
+			 */
+			static void deserialize(nlohmann::json const& value, rttr::variant& result) {
+				if (value.is_array() && result.is_sequential_container()) {
+					auto view = result.create_sequential_view();
+					size_t size = value.size();
+					view.set_size(size);
+					for (size_t i = 0; i < size; ++i) {
+						rttr::variant var_tmp = view.get_value(i).extract_wrapped_value();
+						deserialize(value[i], var_tmp);
+						view.set_value(i, var_tmp);
 					}
-					//list
-					else if (utils::rttr_type<std::vector<int>>(property.get_type()) &&
-						value[prop_name].type() == nlohmann::json::value_t::array) {
-						std::vector<int> item_list;
-						nlohmann::json item_value = value[prop_name];
-						for (auto& it : item_value) {
-							if (it.type() == nlohmann::json::value_t::number_integer ||
-								it.type() == nlohmann::json::value_t::number_unsigned) {
-								item_list.push_back(it.get<int>());
+				}
+				else if (!value.is_array() && !result.is_sequential_container()) {
+					auto properties = result.get_type().get_properties();
+					for (auto& property : properties) {
+						std::string prop_name;
+						rttr::variant no_json = property.get_metadata("NoJson");
+						rttr::variant prop_var_name = property.get_metadata("Json");
+						if (no_json.get_type() == rttr::type::get<bool>() && no_json.get_value<bool>())
+							continue;
+						if (prop_var_name.get_type() == rttr::type::get<std::string>())
+							prop_name = prop_var_name.get_value<std::string>();
+						else
+							prop_name = std::string(property.get_name());
+						if (!value.contains(prop_name))
+							continue;
+
+						if (rttr::type::get<int>() == property.get_type()) {
+							int value_tmp = 0;
+							if (value[prop_name].type() == nlohmann::json::value_t::number_integer ||
+								value[prop_name].type() == nlohmann::json::value_t::number_unsigned) {
+								value_tmp = value[prop_name].get<int>();
 							}
-							else if (it.type() == nlohmann::json::value_t::boolean) {
-								item_list.push_back(it.get<bool>() ? 1 : 0);
+							else if (value[prop_name].type() == nlohmann::json::value_t::boolean) {
+								value_tmp = value[prop_name].get<bool>() ? 1 : 0;
 							}
-							else if (it.type() == nlohmann::json::value_t::number_float) {
-								item_list.push_back(int(it.get<float>()));
+							else if (value[prop_name].type() == nlohmann::json::value_t::number_float) {
+								value_tmp = int(value[prop_name].get<float>());
 							}
-							else if (it.type() == nlohmann::json::value_t::string) {
-								item_list.push_back(std::atoi(it.get<std::string>().c_str()));
+							else if (value[prop_name].type() == nlohmann::json::value_t::string) {
+								value_tmp = std::atoi(value[prop_name].get<std::string>().c_str());
 							}
+							property.set_value(result, value_tmp);
 						}
-						property.set_value(result, item_list);
-					}
-					else if (utils::rttr_type<std::vector<bool>>(property.get_type()) &&
-						value[prop_name].type() == nlohmann::json::value_t::array) {
-						std::vector<bool> item_list;
-						nlohmann::json item_value = value[prop_name];
-						for (auto& it : item_value) {
-							if (it.type() == nlohmann::json::value_t::number_integer ||
-								it.type() == nlohmann::json::value_t::number_unsigned) {
-								item_list.push_back(it.get<int>() > 1);
+						else if (rttr::type::get<bool>() == property.get_type()) {
+							bool value_tmp = false;
+							if (value[prop_name].type() == nlohmann::json::value_t::number_integer ||
+								value[prop_name].type() == nlohmann::json::value_t::number_unsigned) {
+								value_tmp = value[prop_name].get<int>() > 1;
 							}
-							else if (it.type() == nlohmann::json::value_t::boolean) {
-								item_list.push_back(it.get<bool>());
+							else if (value[prop_name].type() == nlohmann::json::value_t::boolean) {
+								value_tmp = value[prop_name].get<bool>();
 							}
-							else if (it.type() == nlohmann::json::value_t::number_float) {
-								item_list.push_back(it.get<float>() > 1);
+							else if (value[prop_name].type() == nlohmann::json::value_t::number_float) {
+								value_tmp = value[prop_name].get<float>() > 1;
 							}
-							else if (it.type() == nlohmann::json::value_t::string) {
-								item_list.push_back(it.get<std::string>() == "true" || it.get<std::string>() == "True" || it.get<std::string>() == "TRUE" || it.get<std::string>() == "1");
+							else if (value[prop_name].type() == nlohmann::json::value_t::string) {
+								value_tmp = value[prop_name].get<std::string>() == "true" || value[prop_name].get<std::string>() == "True" || value[prop_name].get<std::string>() == "TRUE" || value[prop_name].get<std::string>() == "1";
 							}
+							property.set_value(result, value_tmp);
 						}
-						property.set_value(result, item_list);
-					}
-					else if (utils::rttr_type<std::vector<double>>(property.get_type()) &&
-						value[prop_name].type() == nlohmann::json::value_t::array) {
-						std::vector<double> item_list;
-						nlohmann::json item_value = value[prop_name];
-						for (auto& it : item_value) {
-							if (it.type() == nlohmann::json::value_t::number_integer ||
-								it.type() == nlohmann::json::value_t::number_unsigned) {
-								item_list.push_back(it.get<int>());
+						else if (rttr::type::get<double>() == property.get_type()) {
+							double value_tmp = 0;
+							if (value[prop_name].type() == nlohmann::json::value_t::number_integer ||
+								value[prop_name].type() == nlohmann::json::value_t::number_unsigned) {
+								value_tmp = value[prop_name].get<int>();
 							}
-							else if (it.type() == nlohmann::json::value_t::boolean) {
-								item_list.push_back(it.get<bool>() ? 1 : 0);
+							else if (value[prop_name].type() == nlohmann::json::value_t::boolean) {
+								value_tmp = value[prop_name].get<bool>() ? 1 : 0;
 							}
-							else if (it.type() == nlohmann::json::value_t::number_float) {
-								item_list.push_back(it.get<float>());
+							else if (value[prop_name].type() == nlohmann::json::value_t::number_float) {
+								value_tmp = value[prop_name].get<float>();
 							}
-							else if (it.type() == nlohmann::json::value_t::string) {
-								item_list.push_back(std::atof(it.get<std::string>().c_str()));
+							else if (value[prop_name].type() == nlohmann::json::value_t::string) {
+								value_tmp = std::atof(value[prop_name].get<std::string>().c_str());
 							}
+							property.set_value(result, value_tmp);
 						}
-						property.set_value(result, item_list);
-					}
-					else if (utils::rttr_type<std::vector<float>>(property.get_type()) &&
-						value[prop_name].type() == nlohmann::json::value_t::array) {
-						std::vector<float> item_list;
-						nlohmann::json item_value = value[prop_name];
-						for (auto& it : item_value) {
-							if (it.type() == nlohmann::json::value_t::number_integer ||
-								it.type() == nlohmann::json::value_t::number_unsigned) {
-								item_list.push_back(it.get<int>());
+						else if (rttr::type::get<float>() == property.get_type()) {
+							float value_tmp = 0;
+							if (value[prop_name].type() == nlohmann::json::value_t::number_integer ||
+								value[prop_name].type() == nlohmann::json::value_t::number_unsigned) {
+								value_tmp = value[prop_name].get<int>();
 							}
-							else if (it.type() == nlohmann::json::value_t::boolean) {
-								item_list.push_back(it.get<bool>() ? 1 : 0);
+							else if (value[prop_name].type() == nlohmann::json::value_t::boolean) {
+								value_tmp = value[prop_name].get<bool>() ? 1 : 0;
 							}
-							else if (it.type() == nlohmann::json::value_t::number_float) {
-								item_list.push_back(it.get<float>());
+							else if (value[prop_name].type() == nlohmann::json::value_t::number_float) {
+								value_tmp = value[prop_name].get<float>();
 							}
-							else if (it.type() == nlohmann::json::value_t::string) {
-								item_list.push_back(std::atof(it.get<std::string>().c_str()));
+							else if (value[prop_name].type() == nlohmann::json::value_t::string) {
+								value_tmp = std::atof(value[prop_name].get<std::string>().c_str());
 							}
+							property.set_value(result, value_tmp);
 						}
-						property.set_value(result, item_list);
-					}
-					else if (utils::rttr_type<std::vector<std::int64_t>>(property.get_type()) &&
-						value[prop_name].type() == nlohmann::json::value_t::array) {
-						std::vector<std::int64_t> item_list;
-						nlohmann::json item_value = value[prop_name];
-						for (auto& it : item_value) {
-							if (it.type() == nlohmann::json::value_t::number_integer ||
-								it.type() == nlohmann::json::value_t::number_unsigned) {
-								item_list.push_back(it.get<std::int64_t>());
+						else if (rttr::type::get<std::int64_t>() == property.get_type()) {
+							std::int64_t value_tmp = 0;
+							if (value[prop_name].type() == nlohmann::json::value_t::number_integer ||
+								value[prop_name].type() == nlohmann::json::value_t::number_unsigned) {
+								value_tmp = value[prop_name].get<std::int64_t>();
 							}
-							else if (it.type() == nlohmann::json::value_t::boolean) {
-								item_list.push_back(it.get<bool>() ? 1 : 0);
+							else if (value[prop_name].type() == nlohmann::json::value_t::boolean) {
+								value_tmp = value[prop_name].get<bool>() ? 1 : 0;
 							}
-							else if (it.type() == nlohmann::json::value_t::number_float) {
-								item_list.push_back(std::int64_t(it.get<float>()));
+							else if (value[prop_name].type() == nlohmann::json::value_t::number_float) {
+								value_tmp = std::int64_t(value[prop_name].get<float>());
 							}
-							else if (it.type() == nlohmann::json::value_t::string) {
-								item_list.push_back(std::atoll(it.get<std::string>().c_str()));
+							else if (value[prop_name].type() == nlohmann::json::value_t::string) {
+								value_tmp = std::atoll(value[prop_name].get<std::string>().c_str());
 							}
+							property.set_value(result, value_tmp);
 						}
-						property.set_value(result, item_list);
-					}
-					else if (utils::rttr_type<std::vector<datetime>>(property.get_type()) &&
-						value[prop_name].type() == nlohmann::json::value_t::array) {
-						std::vector<datetime> item_list;
-						nlohmann::json item_value = value[prop_name];
-						for (auto& it : item_value) {
-							if (it.type() == nlohmann::json::value_t::number_integer ||
-								it.type() == nlohmann::json::value_t::number_unsigned) {
-								item_list.push_back((time_t)it.get<std::int64_t>());
+						else if (rttr::type::get<v3::datetime>() == property.get_type()) {
+							v3::datetime value_tmp;
+							if (value[prop_name].type() == nlohmann::json::value_t::number_integer ||
+								value[prop_name].type() == nlohmann::json::value_t::number_unsigned) {
+								value_tmp = (time_t)value[prop_name].get<std::int64_t>();
 							}
-							else if (it.type() == nlohmann::json::value_t::number_float) {
-								item_list.push_back(time_t(it.get<float>()));
+							else if (value[prop_name].type() == nlohmann::json::value_t::number_float) {
+								value_tmp = time_t(value[prop_name].get<float>());
 							}
-							else if (it.type() == nlohmann::json::value_t::string) {
-								item_list.push_back(it.get<std::string>());
+							else if (value[prop_name].type() == nlohmann::json::value_t::string) {
+								value_tmp = value[prop_name].get<std::string>();
 							}
+							property.set_value(result, value_tmp);
 						}
-						property.set_value(result, item_list);
-					}
-					else if (utils::rttr_type<std::vector<std::string>>(property.get_type()) &&
-						value[prop_name].type() == nlohmann::json::value_t::array) {
-						std::vector<std::string> item_list;
-						nlohmann::json item_value = value[prop_name];
-						for (auto& it : item_value) {
-							if (it.type() == nlohmann::json::value_t::number_integer ||
-								it.type() == nlohmann::json::value_t::number_unsigned) {
-								item_list.push_back(std::to_string(it.get<std::int64_t>()));
+						else if (rttr::type::get<std::string>() == property.get_type()) {
+							std::string value_tmp;
+							if (value[prop_name].type() == nlohmann::json::value_t::number_integer ||
+								value[prop_name].type() == nlohmann::json::value_t::number_unsigned) {
+								value_tmp = std::to_string(value[prop_name].get<std::int64_t>());
+							}
+							else if (value[prop_name].type() == nlohmann::json::value_t::boolean) {
+								value_tmp = value[prop_name].get<bool>() ? "true" : "false";
+							}
+							else if (value[prop_name].type() == nlohmann::json::value_t::number_float) {
+								value_tmp = std::to_string(value[prop_name].get<float>());
+							}
+							else if (value[prop_name].type() == nlohmann::json::value_t::string) {
+								value_tmp = value[prop_name].get<std::string>();
+							}
+							property.set_value(result, value_tmp);
+						}
+						//list
+						else if (rttr::type::get<std::vector<int>>() == property.get_type() &&
+							value[prop_name].type() == nlohmann::json::value_t::array) {
+							std::vector<int> item_list;
+							nlohmann::json item_value = value[prop_name];
+							for (auto& it : item_value) {
+								if (it.type() == nlohmann::json::value_t::number_integer ||
+									it.type() == nlohmann::json::value_t::number_unsigned) {
+									item_list.push_back(it.get<int>());
+								}
+								else if (it.type() == nlohmann::json::value_t::boolean) {
+									item_list.push_back(it.get<bool>() ? 1 : 0);
+								}
+								else if (it.type() == nlohmann::json::value_t::number_float) {
+									item_list.push_back(int(it.get<float>()));
+								}
+								else if (it.type() == nlohmann::json::value_t::string) {
+									item_list.push_back(std::atoi(it.get<std::string>().c_str()));
+								}
+							}
+							property.set_value(result, item_list);
+						}
+						else if (rttr::type::get<std::vector<bool>>() == property.get_type() &&
+							value[prop_name].type() == nlohmann::json::value_t::array) {
+							std::vector<bool> item_list;
+							nlohmann::json item_value = value[prop_name];
+							for (auto& it : item_value) {
+								if (it.type() == nlohmann::json::value_t::number_integer ||
+									it.type() == nlohmann::json::value_t::number_unsigned) {
+									item_list.push_back(it.get<int>() > 1);
+								}
+								else if (it.type() == nlohmann::json::value_t::boolean) {
+									item_list.push_back(it.get<bool>());
+								}
+								else if (it.type() == nlohmann::json::value_t::number_float) {
+									item_list.push_back(it.get<float>() > 1);
+								}
+								else if (it.type() == nlohmann::json::value_t::string) {
+									item_list.push_back(it.get<std::string>() == "true" || it.get<std::string>() == "True" || it.get<std::string>() == "TRUE" || it.get<std::string>() == "1");
+								}
 							}
-							else if (it.type() == nlohmann::json::value_t::boolean) {
-								item_list.push_back(it.get<bool>() ? "true" : "false");
+							property.set_value(result, item_list);
+						}
+						else if (rttr::type::get<std::vector<double>>() == property.get_type() &&
+							value[prop_name].type() == nlohmann::json::value_t::array) {
+							std::vector<double> item_list;
+							nlohmann::json item_value = value[prop_name];
+							for (auto& it : item_value) {
+								if (it.type() == nlohmann::json::value_t::number_integer ||
+									it.type() == nlohmann::json::value_t::number_unsigned) {
+									item_list.push_back(it.get<int>());
+								}
+								else if (it.type() == nlohmann::json::value_t::boolean) {
+									item_list.push_back(it.get<bool>() ? 1 : 0);
+								}
+								else if (it.type() == nlohmann::json::value_t::number_float) {
+									item_list.push_back(it.get<float>());
+								}
+								else if (it.type() == nlohmann::json::value_t::string) {
+									item_list.push_back(std::atof(it.get<std::string>().c_str()));
+								}
 							}
-							else if (it.type() == nlohmann::json::value_t::number_float) {
-								item_list.push_back(std::to_string(it.get<float>()));
+							property.set_value(result, item_list);
+						}
+						else if (rttr::type::get<std::vector<float>>() == property.get_type() &&
+							value[prop_name].type() == nlohmann::json::value_t::array) {
+							std::vector<float> item_list;
+							nlohmann::json item_value = value[prop_name];
+							for (auto& it : item_value) {
+								if (it.type() == nlohmann::json::value_t::number_integer ||
+									it.type() == nlohmann::json::value_t::number_unsigned) {
+									item_list.push_back(it.get<int>());
+								}
+								else if (it.type() == nlohmann::json::value_t::boolean) {
+									item_list.push_back(it.get<bool>() ? 1 : 0);
+								}
+								else if (it.type() == nlohmann::json::value_t::number_float) {
+									item_list.push_back(it.get<float>());
+								}
+								else if (it.type() == nlohmann::json::value_t::string) {
+									item_list.push_back(std::atof(it.get<std::string>().c_str()));
+								}
 							}
-							else if (it.type() == nlohmann::json::value_t::string) {
-								item_list.push_back(it.get<std::string>());
+							property.set_value(result, item_list);
+						}
+						else if (rttr::type::get<std::vector<std::int64_t>>() == property.get_type() &&
+							value[prop_name].type() == nlohmann::json::value_t::array) {
+							std::vector<std::int64_t> item_list;
+							nlohmann::json item_value = value[prop_name];
+							for (auto& it : item_value) {
+								if (it.type() == nlohmann::json::value_t::number_integer ||
+									it.type() == nlohmann::json::value_t::number_unsigned) {
+									item_list.push_back(it.get<std::int64_t>());
+								}
+								else if (it.type() == nlohmann::json::value_t::boolean) {
+									item_list.push_back(it.get<bool>() ? 1 : 0);
+								}
+								else if (it.type() == nlohmann::json::value_t::number_float) {
+									item_list.push_back(std::int64_t(it.get<float>()));
+								}
+								else if (it.type() == nlohmann::json::value_t::string) {
+									item_list.push_back(std::atoll(it.get<std::string>().c_str()));
+								}
 							}
+							property.set_value(result, item_list);
+						}
+						else if (rttr::type::get<std::vector<v3::datetime>>() == property.get_type() &&
+							value[prop_name].type() == nlohmann::json::value_t::array) {
+							std::vector<v3::datetime> item_list;
+							nlohmann::json item_value = value[prop_name];
+							for (auto& it : item_value) {
+								if (it.type() == nlohmann::json::value_t::number_integer ||
+									it.type() == nlohmann::json::value_t::number_unsigned) {
+									item_list.push_back((time_t)it.get<std::int64_t>());
+								}
+								else if (it.type() == nlohmann::json::value_t::number_float) {
+									item_list.push_back(time_t(it.get<float>()));
+								}
+								else if (it.type() == nlohmann::json::value_t::string) {
+									item_list.push_back(it.get<std::string>());
+								}
+							}
+							property.set_value(result, item_list);
+						}
+						else if (rttr::type::get<std::vector<std::string>>() == property.get_type() &&
+							value[prop_name].type() == nlohmann::json::value_t::array) {
+							std::vector<std::string> item_list;
+							nlohmann::json item_value = value[prop_name];
+							for (auto& it : item_value) {
+								if (it.type() == nlohmann::json::value_t::number_integer ||
+									it.type() == nlohmann::json::value_t::number_unsigned) {
+									item_list.push_back(std::to_string(it.get<std::int64_t>()));
+								}
+								else if (it.type() == nlohmann::json::value_t::boolean) {
+									item_list.push_back(it.get<bool>() ? "true" : "false");
+								}
+								else if (it.type() == nlohmann::json::value_t::number_float) {
+									item_list.push_back(std::to_string(it.get<float>()));
+								}
+								else if (it.type() == nlohmann::json::value_t::string) {
+									item_list.push_back(it.get<std::string>());
+								}
+							}
+							property.set_value(result, item_list);
+						}
+						//object
+						else if (property.get_type().is_sequential_container() &&
+							value[prop_name].type() == nlohmann::json::value_t::array) {
+							rttr::variant var = property.get_value(result);
+							auto view = var.create_sequential_view();
+							size_t size = value[prop_name].size();
+							view.set_size(size);
+							for (size_t i = 0; i < size; ++i) {
+								rttr::variant var_tmp = view.get_value(i).extract_wrapped_value();
+								deserialize(value[prop_name][i], var_tmp);
+								view.set_value(i, var_tmp);
+							}
+							property.set_value(result, var);
+						}
+						//objectlist
+						else if (property.get_type().is_class() &&
+							value[prop_name].type() == nlohmann::json::value_t::object) {
+							rttr::variant child = property.get_value(result);
+							deserialize(value[prop_name], child);
+							property.set_value(result, child);
 						}
-						property.set_value(result, item_list);
-					}
-					//object
-					else if (property.get_type().is_sequential_container() &&
-						value[prop_name].type() == nlohmann::json::value_t::array) {
-						rttr::variant var = property.get_value(result);
-						auto view = var.create_sequential_view();
-						size_t size = value[prop_name].size();
-						view.set_size(size);
-						for (size_t i = 0; i < size; ++i) {
-							rttr::variant var_tmp = view.get_value(i).extract_wrapped_value();
-							deserialize(value[prop_name][i], var_tmp);
-							view.set_value(i, var_tmp);
-						}
-						property.set_value(result, var);
-					}
-					//objectlist
-					else if (property.get_type().is_class() &&
-						value[prop_name].type() == nlohmann::json::value_t::object) {
-						rttr::variant child = property.get_value(result);
-						deserialize(value[prop_name], child);
-						property.set_value(result, child);
 					}
 				}
 			}
-		};
-		class json_convert {
-		public:
-			/**
-			 * @brief 序列化
-			 * @tparam _Type
-			 * @param value
-			 * @param result
-			 */
-			template<typename _Type>
-			static void serialize(_Type const& value, nlohmann::json& result) {
-				json_convert_impl::serialize(value, result);
-			}
-			/**
-			 * @brief 反序列化
-			 * @tparam _Type
-			 * @param value
-			 * @param result
-			 */
-			template<typename _Type>
-			static void deserialize(nlohmann::json const& value, _Type& result) {
-				json_convert_impl::deserialize(value, result);
-			}
-			/**
-			 * @brief 反序列化
-			 * @tparam _Type
-			 * @param value
-			 * @param result
-			 */
-			static void deserialize(std::string const& value, rttr::variant& result) {
-				nlohmann::json json = nlohmann::json::parse(value);
-				json_convert_impl::deserialize(json, result);
-			}
 			/**
 			 * @brief 序列化
 			 * @tparam _Type
@@ -448,52 +439,36 @@ namespace robotics {
 			template<typename _Type>
 			static std::string serialize(_Type const& value) {
 				nlohmann::json result;
-				if constexpr (is_specialization<_Type, std::vector>::value) {
-					result = nlohmann::json::array();
-					for (auto& it : value) {
-						nlohmann::json result_item;
-						serialize(it, result_item);
-						result.push_back(result_item);
-					}
-				}
-				else {
-					serialize(value, result);
-				}
+				serialize(value, result);
 				return result.dump();
 			}
 			/**
 			 * @brief 反序列化
-			 * @tparam _Type
+			 * @tparam _Ret
 			 * @param value
 			 * @param result
+			 * @return
 			 */
-			template<typename _Type>
-			static _Type deserialize(std::string const& value) {
-				_Type result;
+			template<typename _Ret>
+			static _Ret deserialize(std::string const& value, _Ret& result) {
 				nlohmann::json json = nlohmann::json::parse(value);
-				if constexpr (is_specialization<_Type, std::vector>::value) {
-					if (json.type() != nlohmann::json::value_t::array)
-						throw std::runtime_error("not array");
-					for (size_t i = 0; i < json.size(); ++i) {
-						typename _Type::value_type result_item;
-						deserialize(json[i], result_item);
-						result.push_back(result_item);
-					}
-				}
-				else {
-					deserialize(json, result);
-				}
+				rttr::variant ret = std::ref(result);
+				deserialize(json, ret);
 				return result;
 			}
 			/**
 			 * @brief 反序列化
-			 * @tparam _Type
-			 * @param value
-			 * @param result
+			 * @tparam _Ret 
+			 * @param value 
+			 * @return 
 			 */
-			template<typename _Type>
-			static void deserialize(std::string const& value, _Type& result) {
-				result = deserialize<_Type>(value);
+			template<typename _Ret>
+			static _Ret deserialize(std::string const& value) {
+				_Ret result;
+				nlohmann::json json = nlohmann::json::parse(value);
+				rttr::variant ret = std::ref(result);
+				deserialize(json, ret);
+				return result;
 			}
 		};
 	}

+ 1 - 1
robot/robotics/v2/nexus_net_client.hpp

@@ -3122,7 +3122,7 @@ namespace robotics::v2 {
                                                        //身份认证响应
             case nexus_net_msg_type_enum::REPAUTHENTICATE: {
                 subscribe();
-                authorized_event(true, "", "");
+                authorize_event(true, "", "");
                 break;
             }
             case nexus_net_msg_type_enum::REPPUBLISHER: