From a50b4fbe238ea808f01524973e67a48b17552c02 Mon Sep 17 00:00:00 2001 From: chengshichang Date: Mon, 23 Jun 2025 19:47:57 +0800 Subject: [PATCH] Signed-off-by: csc --- services/native/src/work_scheduler_service.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/native/src/work_scheduler_service.cpp b/services/native/src/work_scheduler_service.cpp index b362af5..402a9ff 100644 --- a/services/native/src/work_scheduler_service.cpp +++ b/services/native/src/work_scheduler_service.cpp @@ -406,8 +406,8 @@ bool WorkSchedulerService::GetJsonFromFile(const char *filePath, nlohmann::json std::string data; LoadStringFromFile(realPath.c_str(), data); WS_HILOGI("data read success"); - const nlohmann::json &jsonObj = nlohmann::json::parse(data, nullptr, false); - if (jsonObj.is_null() || jsonObj.empty()) { + root = nlohmann::json::parse(data, nullptr, false); + if (root.is_discarded()) { WS_HILOGE("parse %{private}s json error", realPath.c_str()); WorkSchedUtil::HiSysEventException(LOAD_WORK, __func__, "json parse failed"); return false; @@ -1315,7 +1315,7 @@ void WorkSchedulerService::RefreshPersistedWorks() auto workInfo = it.second; string data = workInfo->ParseToJsonStr(); const nlohmann::json &workJson = nlohmann::json::parse(data, nullptr, false); - if (!workJson.is_null() && !workJson.empty()) { + if (!workJson.is_discarded()) { root[it.first] = workJson; } } -- Gitee