# HG changeset patch # User Alain Mazy # Date 1645720580 -3600 # Node ID 8785d8442f90a9683aa3040f9b44ec529d7b71df # Parent b5994fb2a4d4ef63a9191b653c8baa5163f44b3a skip json comments when loading config diff -r b5994fb2a4d4 -r 8785d8442f90 OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp --- a/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Wed Feb 23 16:08:54 2022 +0100 +++ b/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Thu Feb 24 17:36:20 2022 +0100 @@ -511,6 +511,22 @@ } + void OrthancString::ToJsonWithoutComments(Json::Value& target) const + { + if (str_ == NULL) + { + LogError("Cannot convert an empty memory buffer to JSON"); + ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); + } + + if (!ReadJsonWithoutComments(target, str_)) + { + LogError("Cannot convert some memory buffer to JSON"); + ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); + } + } + + void MemoryBuffer::DicomToJson(Json::Value& target, OrthancPluginDicomToJsonFormat format, OrthancPluginDicomToJsonFlags flags, @@ -645,7 +661,7 @@ ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); } - str.ToJson(configuration_); + str.ToJsonWithoutComments(configuration_); if (configuration_.type() != Json::objectValue) { diff -r b5994fb2a4d4 -r 8785d8442f90 OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.h --- a/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.h Wed Feb 23 16:08:54 2022 +0100 +++ b/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.h Thu Feb 24 17:36:20 2022 +0100 @@ -300,7 +300,9 @@ void ToString(std::string& target) const; void ToJson(Json::Value& target) const; - }; + + void ToJsonWithoutComments(Json::Value& target) const; +}; class OrthancConfiguration : public boost::noncopyable