diff Framework/Toolbox/MessagingToolbox.cpp @ 67:acb60cbb8301 wasm

refactoring SeriesLoader
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 18 May 2017 17:51:41 +0200
parents 28956ed68280
children 2eca030792aa
line wrap: on
line diff
--- a/Framework/Toolbox/MessagingToolbox.cpp	Wed May 17 22:03:09 2017 +0200
+++ b/Framework/Toolbox/MessagingToolbox.cpp	Thu May 18 17:51:41 2017 +0200
@@ -152,8 +152,19 @@
     }
 
 
-    static void ParseJson(Json::Value& target,
-                          const std::string& source)
+    bool ParseJson(Json::Value& target,
+                   const void* content,
+                   size_t size)
+    {
+      Json::Reader reader;
+      return reader.parse(reinterpret_cast<const char*>(content),
+                          reinterpret_cast<const char*>(content) + size,
+                          target);
+    }
+
+
+    static void ParseJsonException(Json::Value& target,
+                                   const std::string& source)
     {
       Json::Reader reader;
       if (!reader.parse(source, target))
@@ -169,7 +180,7 @@
     {
       std::string tmp;
       orthanc.RestApiGet(tmp, uri);
-      ParseJson(target, tmp);
+      ParseJsonException(target, tmp);
     }
 
 
@@ -180,7 +191,7 @@
     {
       std::string tmp;
       orthanc.RestApiPost(tmp, uri, body);
-      ParseJson(target, tmp);
+      ParseJsonException(target, tmp);
     }