change json api deprecated 66/261766/2 accepted/tizen_6.5_unified accepted/tizen_7.0_unified accepted/tizen_7.0_unified_hotfix tizen_6.5 tizen_7.0 tizen_7.0_hotfix accepted/tizen/6.5/unified/20211028.101605 accepted/tizen/7.0/unified/20221110.063658 accepted/tizen/7.0/unified/hotfix/20221116.105250 accepted/tizen/unified/20210803.123906 submit/tizen/20210802.223411 submit/tizen_6.5/20211028.162201 tizen_6.5.m2_release tizen_7.0_m2_release
authorYoungjae Shin <yj99.shin@samsung.com>
Mon, 26 Jul 2021 02:07:26 +0000 (11:07 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Mon, 2 Aug 2021 22:27:12 +0000 (07:27 +0900)
Change-Id: I51efe034f7d3518c84238f7c359f2e12cbea3050

src/client/job_scheduler.cpp
src/server/MethodCallHandler.cpp
src/shared/JobInfo.cpp

index a9ddaa3..f66791c 100644 (file)
@@ -646,10 +646,9 @@ EXPORT_API const char* ctx_sched_job_serialize(ctx_sched_job_h job)
        static std::string serialized;
 
        Json::Value jsonRoot;
-       Json::StyledWriter writer;
 
        job->jobInfo->toJson(jsonRoot);
-       serialized = writer.write(jsonRoot);
+       serialized = jsonRoot.toStyledString();
 
        return serialized.c_str();
 }
@@ -659,10 +658,9 @@ EXPORT_API const char* ctx_sched_job_context_serialize(ctx_sched_job_context_h j
        static std::string serialized;
 
        Json::Value jsonRoot;
-       Json::StyledWriter writer;
 
        job_context->jobContext->toJson(jsonRoot);
-       serialized = writer.write(jsonRoot);
+       serialized = jsonRoot.toStyledString();
 
        return serialized.c_str();
 }
index b6b047e..3d8832b 100644 (file)
@@ -254,11 +254,13 @@ void MethodCallHandler::__publishContext(IMethodCall& methodCall)
        g_variant_get(methodCall.getParam(), "(&s&s)", &uri, &payload);
        IF_FAIL_THROW(uri && payload, E_PARAM);
 
-       try {
-               Json::Reader reader;
-               reader.parse(payload, data);
-       } catch (const Json::Exception& e) {
-               _E("Exception: %s", e.what());
+       std::string errors;
+       Json::CharReaderBuilder builder;
+       Json::CharReader *reader = builder.newCharReader();
+       bool result= reader->parse(payload, payload + strlen(payload), &data, &errors);
+       delete reader;
+       if (result == false) {
+               _E("parse Error(%s)", errors.c_str());
                throw E_PARAM;
        }
 
index 52936a7..4118fce 100644 (file)
@@ -203,10 +203,10 @@ std::string JobInfo::serialize() const
        Json::Value jsonRoot;
        toJson(jsonRoot);
 
-       Json::FastWriter fastWriter;
-       fastWriter.omitEndingLineFeed();
+       Json::StreamWriterBuilder builder;
+       builder["indentation"] = "";
 
-       return fastWriter.write(jsonRoot);
+       return Json::writeString(builder, jsonRoot);
 }
 
 void JobInfo::toJson(Json::Value& jsonRoot) const
@@ -268,12 +268,15 @@ JobInfo& JobInfo::setDisjunction(bool disjunction)
 
 JobInfo* JobInfo::deserialize(const std::string& serializedStr)
 {
-       Json::Reader reader;
        Json::Value jsonRoot;
        JobInfo* job = NULL;
 
        try {
-               if (reader.parse(serializedStr, jsonRoot)) {
+               std::string errors;
+               Json::CharReaderBuilder builder;
+               std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
+
+               if (reader->parse(serializedStr.c_str(), serializedStr.c_str() + serializedStr.size(), &jsonRoot, &errors)) {
                        JobInfo::Type type = static_cast<JobInfo::Type>(jsonRoot[KEY_JOB_TYPE].asInt());
                        if (type == JobInfo::Type::PERIODIC) {
                                job = new PeriodicJobInfo(jsonRoot, serializedStr);