# HG changeset patch # User Sebastien Jodogne # Date 1478523576 -3600 # Node ID bfa92c9328d76c35de94e9849383b9e0466969ff # Parent 03b065778fc33615b3de676fdd8ad1879e672b41 cleaning up diff -r 03b065778fc3 -r bfa92c9328d7 OrthancServer/OrthancRestApi/OrthancRestResources.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Mon Nov 07 13:47:21 2016 +0100 +++ b/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Mon Nov 07 13:59:36 2016 +0100 @@ -215,7 +215,9 @@ } else { - context.AnswerAttachment(call.GetOutput(), publicId, FileContentType_DicomAsJson); + std::string full; + context.ReadDicomAsJson(full, publicId); + call.GetOutput().AnswerBuffer(full, "application/json"); } } diff -r 03b065778fc3 -r bfa92c9328d7 OrthancServer/ServerContext.cpp --- a/OrthancServer/ServerContext.cpp Mon Nov 07 13:47:21 2016 +0100 +++ b/OrthancServer/ServerContext.cpp Mon Nov 07 13:59:36 2016 +0100 @@ -368,14 +368,21 @@ } + void ServerContext::ReadDicomAsJson(std::string& result, + const std::string& instancePublicId) + { + ReadFile(result, instancePublicId, FileContentType_DicomAsJson, true /* decompress if needed */); + } + + void ServerContext::ReadDicomAsJson(Json::Value& result, const std::string& instancePublicId) { - std::string s; - ReadFile(s, instancePublicId, FileContentType_DicomAsJson, true /* decompress if needed */); + std::string tmp; + ReadDicomAsJson(tmp, instancePublicId); Json::Reader reader; - if (!reader.parse(s, result)) + if (!reader.parse(tmp, result)) { throw OrthancException(ErrorCode_CorruptedFile); } diff -r 03b065778fc3 -r bfa92c9328d7 OrthancServer/ServerContext.h --- a/OrthancServer/ServerContext.h Mon Nov 07 13:47:21 2016 +0100 +++ b/OrthancServer/ServerContext.h Mon Nov 07 13:59:36 2016 +0100 @@ -191,6 +191,9 @@ FileContentType attachmentType, CompressionType compression); + void ReadDicomAsJson(std::string& result, + const std::string& instancePublicId); + void ReadDicomAsJson(Json::Value& result, const std::string& instancePublicId);