changeset 484:bcf2a61b5627

remove calls to deprecated Json::Reader
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 22 Dec 2020 08:21:17 +0100
parents 34b47baaec05
children 8b45dbd82f1f
files Plugin/Configuration.cpp Plugin/DicomWebClient.cpp Plugin/DicomWebFormatter.cpp Plugin/QidoRs.cpp
diffstat 4 files changed, 5 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/Plugin/Configuration.cpp	Fri Dec 18 07:18:42 2020 +0100
+++ b/Plugin/Configuration.cpp	Tue Dec 22 08:21:17 2020 +0100
@@ -28,7 +28,6 @@
 #include <Toolbox.h>
 
 #include <fstream>
-#include <json/reader.h>
 #include <boost/regex.hpp>
 #include <boost/lexical_cast.hpp>
 #include <boost/algorithm/string/predicate.hpp>
@@ -156,9 +155,7 @@
   void ParseJsonBody(Json::Value& target,
                      const OrthancPluginHttpRequest* request)
   {
-    Json::Reader reader;
-    if (!reader.parse(reinterpret_cast<const char*>(request->body),
-                      reinterpret_cast<const char*>(request->body) + request->bodySize, target))
+    if (!Orthanc::Toolbox::ReadJson(target, request->body, request->bodySize))
     {
       throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat,
                                       "A JSON file was expected");
--- a/Plugin/DicomWebClient.cpp	Fri Dec 18 07:18:42 2020 +0100
+++ b/Plugin/DicomWebClient.cpp	Tue Dec 22 08:21:17 2020 +0100
@@ -30,7 +30,6 @@
 #include <Logging.h>
 #include <Toolbox.h>
 
-#include <json/reader.h>
 #include <list>
 #include <set>
 #include <boost/lexical_cast.hpp>
--- a/Plugin/DicomWebFormatter.cpp	Fri Dec 18 07:18:42 2020 +0100
+++ b/Plugin/DicomWebFormatter.cpp	Tue Dec 22 08:21:17 2020 +0100
@@ -23,8 +23,8 @@
 
 #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h"
 
-#if !defined(NDEBUG)
-#  include <json/reader.h>
+#if !defined(NDEBUG)  // In debug mode, check that the value is actually a JSON string
+#  include <Toolbox.h>
 #endif
 
 
@@ -217,10 +217,8 @@
     }
 
 #if !defined(NDEBUG)  // In debug mode, check that the value is actually a JSON string
-    Json::Reader reader;
     Json::Value json;
-    if (!reader.parse(reinterpret_cast<const char*>(data),
-                      reinterpret_cast<const char*>(data) + size, json))
+    if (!Orthanc::Toolbox::ReadJson(json, data, size))
     {
       throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
     }
--- a/Plugin/QidoRs.cpp	Fri Dec 18 07:18:42 2020 +0100
+++ b/Plugin/QidoRs.cpp	Tue Dec 22 08:21:17 2020 +0100
@@ -492,11 +492,7 @@
   LOG(INFO) << "Body of the call from QIDO-RS to /tools/find: " << find.toStyledString();
   
   std::string body;
-
-  {
-    Json::FastWriter writer;
-    body = writer.write(find);
-  }
+  Orthanc::Toolbox::WriteJson(body, find, true /* fast */);
   
   Json::Value resources;
   if (!OrthancPlugins::RestApiPost(resources, "/tools/find", body, false) ||