Mercurial > hg > orthanc-stone
changeset 1737:ef2f56c0311c
remove calls to deprecated classes of JsonCpp
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 22 Dec 2020 09:16:42 +0100 |
parents | 77038e2bd074 |
children | 05dc12df49db |
files | Applications/StoneWebViewer/Plugin/Plugin.cpp OrthancStone/Sources/Loaders/DicomResourcesLoader.cpp OrthancStone/Sources/Loaders/DicomSource.cpp OrthancStone/Sources/Loaders/SeriesThumbnailsLoader.cpp OrthancStone/Sources/Oracle/GetOrthancWebViewerJpegCommand.cpp OrthancStone/Sources/Oracle/OrthancRestApiCommand.cpp OrthancStone/Sources/Toolbox/OrthancDatasets/IOrthancConnection.cpp |
diffstat | 7 files changed, 18 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- 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)
--- 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 <DicomParsing/ParsedDicomFile.h> #endif +#include <Toolbox.h> + #include <boost/filesystem/path.hpp> 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); }
--- 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 <OrthancException.h> +#include <Toolbox.h> #include <boost/algorithm/string/predicate.hpp> @@ -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) &&
--- 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 <Images/JpegReader.h> #include <Images/JpegWriter.h> #include <OrthancException.h> +#include <Toolbox.h> #include <boost/algorithm/string/predicate.hpp> @@ -210,10 +211,9 @@ virtual void HandleSuccess(const std::string& body, const std::map<std::string, std::string>& 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);
--- 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 <OrthancException.h> #include <Toolbox.h> -#ifdef _MSC_VER -// 'Json::Reader': Use CharReader and CharReaderBuilder instead -#pragma warning(disable:4996) -#endif - -#include <json/reader.h> #include <json/value.h> 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 ||
--- 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 <Logging.h> #include <OrthancException.h> +#include <Toolbox.h> -#ifdef _MSC_VER -// 'Json::Reader': Use CharReader and CharReaderBuilder instead -#pragma warning(disable:4996) -#endif - -#include <json/reader.h> -#include <json/writer.h> 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); }
--- 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 <OrthancException.h> - -#include <json/reader.h> +#include <Toolbox.h> 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<const char*>(content), - reinterpret_cast<const char*>(content) + size, result)) + if (!Orthanc::Toolbox::ReadJson(result, content, size)) { throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); }