# HG changeset patch # User Sebastien Jodogne # Date 1608625002 -3600 # Node ID ef2f56c0311c5dc5bd6c764e28ba1b768a285a61 # Parent 77038e2bd07485aeefd01c97e0c66d86037cda85 remove calls to deprecated classes of JsonCpp diff -r 77038e2bd074 -r ef2f56c0311c Applications/StoneWebViewer/Plugin/Plugin.cpp --- a/Applications/StoneWebViewer/Plugin/Plugin.cpp Tue Dec 22 09:06:33 2020 +0100 +++ b/Applications/StoneWebViewer/Plugin/Plugin.cpp Tue Dec 22 09:16:42 2020 +0100 @@ -171,9 +171,8 @@ Orthanc::EmbeddedResources::GetDirectoryResource( s, Orthanc::EmbeddedResources::WEB_APPLICATION, "/configuration.json"); - Json::Reader reader; Json::Value full; - if (!reader.parse(s, full) || + if (!Orthanc::Toolbox::ReadJson(full, s) || full.type() != Json::objectValue || !full.isMember(CONFIG_SECTION) || full[CONFIG_SECTION].type() != Json::objectValue) diff -r 77038e2bd074 -r ef2f56c0311c OrthancStone/Sources/Loaders/DicomResourcesLoader.cpp --- a/OrthancStone/Sources/Loaders/DicomResourcesLoader.cpp Tue Dec 22 09:06:33 2020 +0100 +++ b/OrthancStone/Sources/Loaders/DicomResourcesLoader.cpp Tue Dec 22 09:16:42 2020 +0100 @@ -32,6 +32,8 @@ # include #endif +#include + #include namespace OrthancStone @@ -141,9 +143,8 @@ virtual void HandleString(const std::string& body) { - Json::Reader reader; Json::Value value; - if (reader.parse(body, value)) + if (Orthanc::Toolbox::ReadJson(value, body)) { HandleJson(value); } diff -r 77038e2bd074 -r ef2f56c0311c OrthancStone/Sources/Loaders/DicomSource.cpp --- a/OrthancStone/Sources/Loaders/DicomSource.cpp Tue Dec 22 09:06:33 2020 +0100 +++ b/OrthancStone/Sources/Loaders/DicomSource.cpp Tue Dec 22 09:16:42 2020 +0100 @@ -26,6 +26,7 @@ #include "../Oracle/OrthancRestApiCommand.h" #include +#include #include @@ -268,9 +269,8 @@ } Json::Value a, b; - Json::Reader reader; - if (reader.parse(system, a) && - reader.parse(plugins, b) && + if (Orthanc::Toolbox::ReadJson(a, system) && + Orthanc::Toolbox::ReadJson(b, plugins) && a.type() == Json::objectValue && b.type() == Json::arrayValue && a.isMember(REST_API_VERSION) && diff -r 77038e2bd074 -r ef2f56c0311c OrthancStone/Sources/Loaders/SeriesThumbnailsLoader.cpp --- a/OrthancStone/Sources/Loaders/SeriesThumbnailsLoader.cpp Tue Dec 22 09:06:33 2020 +0100 +++ b/OrthancStone/Sources/Loaders/SeriesThumbnailsLoader.cpp Tue Dec 22 09:16:42 2020 +0100 @@ -33,6 +33,7 @@ #include #include #include +#include #include @@ -210,10 +211,9 @@ virtual void HandleSuccess(const std::string& body, const std::map& headers) ORTHANC_OVERRIDE { - Json::Reader reader; Json::Value value; - if (!reader.parse(body, value) || + if (!Orthanc::Toolbox::ReadJson(value, body) || value.type() != Json::arrayValue) { throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); @@ -389,8 +389,7 @@ static const char* const INSTANCES = "Instances"; Json::Value json; - Json::Reader reader; - if (!reader.parse(body, json) || + if (!Orthanc::Toolbox::ReadJson(json, body) || json.type() != Json::objectValue) { throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); diff -r 77038e2bd074 -r ef2f56c0311c OrthancStone/Sources/Oracle/GetOrthancWebViewerJpegCommand.cpp --- a/OrthancStone/Sources/Oracle/GetOrthancWebViewerJpegCommand.cpp Tue Dec 22 09:06:33 2020 +0100 +++ b/OrthancStone/Sources/Oracle/GetOrthancWebViewerJpegCommand.cpp Tue Dec 22 09:16:42 2020 +0100 @@ -30,12 +30,6 @@ #include #include -#ifdef _MSC_VER -// 'Json::Reader': Use CharReader and CharReaderBuilder instead -#pragma warning(disable:4996) -#endif - -#include #include namespace OrthancStone @@ -77,13 +71,9 @@ // This code comes from older "OrthancSlicesLoader::ParseSliceImageJpeg()" Json::Value encoded; - + if (!Orthanc::Toolbox::ReadJson(encoded, answer)) { - Json::Reader reader; - if (!reader.parse(answer, encoded)) - { - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); - } + throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); } if (encoded.type() != Json::objectValue || diff -r 77038e2bd074 -r ef2f56c0311c OrthancStone/Sources/Oracle/OrthancRestApiCommand.cpp --- a/OrthancStone/Sources/Oracle/OrthancRestApiCommand.cpp Tue Dec 22 09:06:33 2020 +0100 +++ b/OrthancStone/Sources/Oracle/OrthancRestApiCommand.cpp Tue Dec 22 09:16:42 2020 +0100 @@ -24,21 +24,14 @@ #include #include +#include -#ifdef _MSC_VER -// 'Json::Reader': Use CharReader and CharReaderBuilder instead -#pragma warning(disable:4996) -#endif - -#include -#include namespace OrthancStone { void OrthancRestApiCommand::SuccessMessage::ParseJsonBody(Json::Value& target) const { - Json::Reader reader; - if (!reader.parse(answer_, target)) + if (!Orthanc::Toolbox::ReadJson(target, answer_)) { throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); } @@ -56,8 +49,7 @@ void OrthancRestApiCommand::SetBody(const Json::Value& json) { - Json::FastWriter writer; - body_ = writer.write(json); + Orthanc::Toolbox::WriteFastJson(body_, json); } diff -r 77038e2bd074 -r ef2f56c0311c OrthancStone/Sources/Toolbox/OrthancDatasets/IOrthancConnection.cpp --- a/OrthancStone/Sources/Toolbox/OrthancDatasets/IOrthancConnection.cpp Tue Dec 22 09:06:33 2020 +0100 +++ b/OrthancStone/Sources/Toolbox/OrthancDatasets/IOrthancConnection.cpp Tue Dec 22 09:16:42 2020 +0100 @@ -23,17 +23,14 @@ #include "IOrthancConnection.h" #include - -#include +#include namespace OrthancStone { void IOrthancConnection::ParseJson(Json::Value& result, const std::string& content) { - Json::Reader reader; - - if (!reader.parse(content, result)) + if (!Orthanc::Toolbox::ReadJson(result, content)) { throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); } @@ -44,10 +41,7 @@ const void* content, size_t size) { - Json::Reader reader; - - if (!reader.parse(reinterpret_cast(content), - reinterpret_cast(content) + size, result)) + if (!Orthanc::Toolbox::ReadJson(result, content, size)) { throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); }