Mercurial > hg > orthanc-stone
changeset 64:394e63010e02 wasm
ParseJson
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 16 May 2017 17:31:09 +0200 |
parents | a4497c6449df |
children | 885932a893de |
files | Resources/Orthanc/Plugins/Samples/Common/FullOrthancDataset.cpp Resources/Orthanc/Plugins/Samples/Common/FullOrthancDataset.h Resources/Orthanc/Plugins/Samples/Common/IOrthancConnection.cpp Resources/Orthanc/Plugins/Samples/Common/IOrthancConnection.h |
diffstat | 4 files changed, 29 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/Resources/Orthanc/Plugins/Samples/Common/FullOrthancDataset.cpp Wed May 10 17:57:24 2017 +0200 +++ b/Resources/Orthanc/Plugins/Samples/Common/FullOrthancDataset.cpp Tue May 16 17:31:09 2017 +0200 @@ -166,6 +166,14 @@ } + FullOrthancDataset::FullOrthancDataset(const void* content, + size_t size) + { + IOrthancConnection::ParseJson(root_, content); + CheckRoot(); + } + + bool FullOrthancDataset::GetStringValue(std::string& result, const DicomPath& path) const {
--- a/Resources/Orthanc/Plugins/Samples/Common/FullOrthancDataset.h Wed May 10 17:57:24 2017 +0200 +++ b/Resources/Orthanc/Plugins/Samples/Common/FullOrthancDataset.h Tue May 16 17:31:09 2017 +0200 @@ -55,6 +55,9 @@ FullOrthancDataset(const std::string& content); + FullOrthancDataset(const void* content, + size_t size); + virtual bool GetStringValue(std::string& result, const DicomPath& path) const;
--- a/Resources/Orthanc/Plugins/Samples/Common/IOrthancConnection.cpp Wed May 10 17:57:24 2017 +0200 +++ b/Resources/Orthanc/Plugins/Samples/Common/IOrthancConnection.cpp Tue May 16 17:31:09 2017 +0200 @@ -51,6 +51,20 @@ } + void IOrthancConnection::ParseJson(Json::Value& result, + const void* content, + size_t size) + { + Json::Reader reader; + + if (!reader.parse(reinterpret_cast<const char*>(content), + reinterpret_cast<const char*>(content) + size, result)) + { + ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); + } + } + + void IOrthancConnection::RestApiGet(Json::Value& result, IOrthancConnection& orthanc, const std::string& uri)
--- a/Resources/Orthanc/Plugins/Samples/Common/IOrthancConnection.h Wed May 10 17:57:24 2017 +0200 +++ b/Resources/Orthanc/Plugins/Samples/Common/IOrthancConnection.h Tue May 16 17:31:09 2017 +0200 @@ -64,6 +64,10 @@ static void ParseJson(Json::Value& result, const std::string& content); + static void ParseJson(Json::Value& result, + const void* content, + size_t size); + static void RestApiGet(Json::Value& result, IOrthancConnection& orthanc, const std::string& uri);