refactor(navigation): 移除冗余的json值类型转换
简化日志输出中对json值的处理,直接使用value方法获取值而不再显式调用get方法
This commit is contained in:
@@ -46,11 +46,11 @@ bool Navigation::callSlamService(int api_id, const nlohmann::json& data) {
|
||||
try {
|
||||
nlohmann::json response_json = nlohmann::json::parse(response_str);
|
||||
if (response_json.contains("succeed") && response_json["succeed"].get<bool>()) {
|
||||
LOG_INFO("Slam service call for api_id " + std::to_string(api_id) + " succeeded. Info: " + response_json.value("info", "").get<std::string>());
|
||||
LOG_INFO("Slam service call for api_id " + std::to_string(api_id) + " succeeded. Info: " + response_json.value("info", ""));
|
||||
return true;
|
||||
} else {
|
||||
LOG_ERROR("Slam service call for api_id " + std::to_string(api_id) + " failed. Error code: " +
|
||||
std::to_string(response_json.value("errorCode", -1).get<int>()) + ", Info: " + response_json.value("info", "").get<std::string>());
|
||||
std::to_string(response_json.value("errorCode", -1)) + ", Info: " + response_json.value("info", ""));
|
||||
return false;
|
||||
}
|
||||
} catch (const nlohmann::json::parse_error& e) {
|
||||
|
||||
Reference in New Issue
Block a user