JsonHelper.h 381 B

123456789101112131415161718
  1. #pragma once
  2. #include <string>
  3. #include <json.hpp>
  4. #include "../pub/LogOutput.h"
  5. template <typename ValueType>
  6. bool W_JsonContains(const nlohmann::json& json, std::string field, ValueType& value)
  7. {
  8. if (json.contains(field)) {
  9. json.at(field).get_to<ValueType>(value);
  10. return true;
  11. }
  12. else
  13. {
  14. LOG_INFO("common W_JsonContains Have No {}", field.c_str());
  15. return false;
  16. }
  17. }