diff OrthancFramework/Sources/RestApi/RestApiOutput.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 bf7b9edf6b81
children f7104e9d044c
line wrap: on
line diff
--- a/OrthancFramework/Sources/RestApi/RestApiOutput.cpp	Mon Dec 21 08:47:29 2020 +0100
+++ b/OrthancFramework/Sources/RestApi/RestApiOutput.cpp	Mon Dec 21 18:09:47 2020 +0100
@@ -95,9 +95,8 @@
     }
     else
     {
-      Json::StyledWriter writer;
-      std::string s = writer.write(value);
-      
+      std::string s;
+      Toolbox::WriteJson(s, value, false /* styled, not fast */);
       output_.SetContentType(MIME_JSON_UTF8);      
       output_.Answer(s);
     }
@@ -122,9 +121,7 @@
         contentType == MimeType_Json)
     {
       Json::Value json;
-      Json::Reader reader;
-      if (reader.parse(reinterpret_cast<const char*>(buffer),
-                       reinterpret_cast<const char*>(buffer) + length, json))
+      if (Toolbox::ReadJson(json, buffer, length))
       {
         AnswerJson(json);
       }