diff OrthancFramework/Sources/Lua/LuaContext.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 b30a8de92ad9
children f7104e9d044c
line wrap: on
line diff
--- a/OrthancFramework/Sources/Lua/LuaContext.cpp	Mon Dec 21 08:47:29 2020 +0100
+++ b/OrthancFramework/Sources/Lua/LuaContext.cpp	Mon Dec 21 18:09:47 2020 +0100
@@ -113,8 +113,7 @@
     const char* str = lua_tostring(state, 1);
 
     Json::Value value;
-    Json::Reader reader;
-    if (reader.parse(str, str + strlen(str), value))
+    if (Toolbox::ReadJson(value, str, strlen(str)))
     {
       that.PushJson(value);
     }
@@ -148,8 +147,8 @@
     Json::Value json;
     that.GetJson(json, state, 1, keepStrings);
 
-    Json::FastWriter writer;
-    std::string s = writer.write(json);
+    std::string s;
+    Toolbox::WriteJson(s, json, true /* fast */);
     lua_pushlstring(state, s.c_str(), s.size());
 
     return 1;
@@ -635,8 +634,7 @@
     std::string s;
     ExecuteInternal(&s, command);
 
-    Json::Reader reader;
-    if (!reader.parse(s, output))
+    if (!Toolbox::ReadJson(output, s))
     {
       throw OrthancException(ErrorCode_BadJson);
     }