| 35 | |
| 36 | template <class T> |
| 37 | static std::optional<T> openhd_json_parse(const std::string& content) { |
| 38 | try { |
| 39 | nlohmann::json j = nlohmann::json::parse(content); |
| 40 | auto tmp = j.get<T>(); |
| 41 | return tmp; |
| 42 | } catch (nlohmann::json::exception& ex) { |
| 43 | // openhd::log::get_default()->warn("openhd_json_parse {}",ex.what()); |
| 44 | std::stringstream ss; |
| 45 | ss << "openhd_json_parse error:" << ex.what() << "\n"; |
| 46 | ss << content; |
| 47 | std::cout << ss.str() << std::endl; |
| 48 | return std::nullopt; |
| 49 | } |
| 50 | return std::nullopt; |
| 51 | }; |
| 52 | |
| 53 | #endif // OPENHD_OPENHD_OHD_COMMON_INCLUDE_JSON_H_ |
nothing calls this directly
no outgoing calls
no test coverage detected