diff OrthancFramework/Sources/Toolbox.cpp @ 4394:f7104e9d044c

functions to read/write JSON in OrthancPluginCppWrapper.h
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 22 Dec 2020 08:11:37 +0100
parents e8e95b80194f
children d07a65100a95
line wrap: on
line diff
--- a/OrthancFramework/Sources/Toolbox.cpp	Mon Dec 21 18:55:32 2020 +0100
+++ b/OrthancFramework/Sources/Toolbox.cpp	Tue Dec 22 08:11:37 2020 +0100
@@ -2336,34 +2336,30 @@
   }
   
 
-  void Toolbox::WriteJson(std::string& target,
-                          const Json::Value& source,
-                          bool fast)
+  void Toolbox::WriteFastJson(std::string& target,
+                              const Json::Value& source)
   {
 #if JSONCPP_USE_DEPRECATED == 1
-    if (fast)
-    {
-      Json::FastWriter writer;
-      target = writer.write(source);
-    }
-    else
-    {
-      Json::StyledWriter writer;
-      target = writer.write(source);
-    }
+    Json::FastWriter writer;
+    target = writer.write(source);
 #else
-    if (fast)
-    {
-      Json::StreamWriterBuilder builder;
-      builder.settings_["indentation"] = "";
-      target = Json::writeString(builder, source);
-    }
-    else
-    {
-      Json::StreamWriterBuilder builder;
-      builder.settings_["indentation"] = "   ";
-      target = Json::writeString(builder, source);
-    }
+    Json::StreamWriterBuilder builder;
+    builder.settings_["indentation"] = "";
+    target = Json::writeString(builder, source);
+#endif
+  }
+  
+
+  void Toolbox::WriteStyledJson(std::string& target,
+                                const Json::Value& source)
+  {
+#if JSONCPP_USE_DEPRECATED == 1
+    Json::StyledWriter writer;
+    target = writer.write(source);
+#else
+    Json::StreamWriterBuilder builder;
+    builder.settings_["indentation"] = "   ";
+    target = Json::writeString(builder, source);
 #endif
   }
 }