comparison Plugin/ViewerToolbox.cpp @ 292:aadbffcee805

remove calls to deprecated classes of JsonCpp
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 22 Dec 2020 09:03:24 +0100
parents ec1af1fdcaca
children e376158e2dbb
comparison
equal deleted inserted replaced
291:0cd081608fd3 292:aadbffcee805
26 #include <Toolbox.h> 26 #include <Toolbox.h>
27 27
28 // To gain access to ORTHANC_PLUGINS_VERSION_IS_ABOVE if Orthanc SDK <= 1.3.0 28 // To gain access to ORTHANC_PLUGINS_VERSION_IS_ABOVE if Orthanc SDK <= 1.3.0
29 #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" 29 #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h"
30 30
31 #include <json/reader.h>
32 #include <stdexcept> 31 #include <stdexcept>
33 #include <boost/lexical_cast.hpp> 32 #include <boost/lexical_cast.hpp>
34 #include <sys/stat.h> 33 #include <sys/stat.h>
35 34
36 namespace OrthancPlugins 35 namespace OrthancPlugins
77 76
78 if (answer.size) 77 if (answer.size)
79 { 78 {
80 try 79 try
81 { 80 {
82 const char* data = reinterpret_cast<const char*>(answer.data); 81 if (!Orthanc::Toolbox::ReadJsonWithoutComments(json, answer.data, answer.size))
83 Json::Reader reader;
84 if (!reader.parse(data, data + answer.size, json,
85 false /* don't collect comments */))
86 { 82 {
87 return false; 83 return false;
88 } 84 }
89 } 85 }
90 catch (std::runtime_error&) 86 catch (std::runtime_error&)
225 221
226 s.assign(tmp); 222 s.assign(tmp);
227 OrthancPluginFreeString(context, tmp); 223 OrthancPluginFreeString(context, tmp);
228 } 224 }
229 225
230 Json::Reader reader; 226 if (Orthanc::Toolbox::ReadJson(configuration, s))
231 if (reader.parse(s, configuration))
232 { 227 {
233 return true; 228 return true;
234 } 229 }
235 else 230 else
236 { 231 {