comparison OrthancServer/Plugins/Engine/PluginsJob.cpp @ 4392:3af1d763763a

confining Json::Reader and Json::*Writer into Toolbox
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 21 Dec 2020 18:09:47 +0100
parents 05b8fd21089c
children d9473bd5ed43
comparison
equal deleted inserted replaced
4391:0c4ff5609548 4392:3af1d763763a
39 #endif 39 #endif
40 40
41 41
42 #include "../../../OrthancFramework/Sources/Logging.h" 42 #include "../../../OrthancFramework/Sources/Logging.h"
43 #include "../../../OrthancFramework/Sources/OrthancException.h" 43 #include "../../../OrthancFramework/Sources/OrthancException.h"
44 #include "../../../OrthancFramework/Sources/Toolbox.h"
44 45
45 #include <json/reader.h>
46 #include <cassert> 46 #include <cassert>
47 47
48 namespace Orthanc 48 namespace Orthanc
49 { 49 {
50 PluginsJob::PluginsJob(const _OrthancPluginCreateJob& parameters) : 50 PluginsJob::PluginsJob(const _OrthancPluginCreateJob& parameters) :
141 { 141 {
142 value = Json::objectValue; 142 value = Json::objectValue;
143 } 143 }
144 else 144 else
145 { 145 {
146 Json::Reader reader; 146 if (!Toolbox::ReadJson(value, content) ||
147
148 if (!reader.parse(content, value) ||
149 value.type() != Json::objectValue) 147 value.type() != Json::objectValue)
150 { 148 {
151 throw OrthancException(ErrorCode_Plugin, 149 throw OrthancException(ErrorCode_Plugin,
152 "A job plugin must provide a JSON object as its public content"); 150 "A job plugin must provide a JSON object as its public content");
153 } 151 }
162 { 160 {
163 return false; 161 return false;
164 } 162 }
165 else 163 else
166 { 164 {
167 Json::Reader reader; 165 if (!Toolbox::ReadJson(value, serialized) ||
168
169 if (!reader.parse(serialized, value) ||
170 value.type() != Json::objectValue) 166 value.type() != Json::objectValue)
171 { 167 {
172 throw OrthancException(ErrorCode_Plugin, 168 throw OrthancException(ErrorCode_Plugin,
173 "A job plugin must provide a JSON object as its serialized content"); 169 "A job plugin must provide a JSON object as its serialized content");
174 } 170 }