comparison OrthancFramework/Sources/RestApi/RestApiOutput.cpp @ 4392:3af1d763763a

confining Json::Reader and Json::*Writer into Toolbox
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 21 Dec 2020 18:09:47 +0100
parents bf7b9edf6b81
children f7104e9d044c
comparison
equal deleted inserted replaced
4391:0c4ff5609548 4392:3af1d763763a
93 "Orthanc was compiled without XML support"); 93 "Orthanc was compiled without XML support");
94 #endif 94 #endif
95 } 95 }
96 else 96 else
97 { 97 {
98 Json::StyledWriter writer; 98 std::string s;
99 std::string s = writer.write(value); 99 Toolbox::WriteJson(s, value, false /* styled, not fast */);
100
101 output_.SetContentType(MIME_JSON_UTF8); 100 output_.SetContentType(MIME_JSON_UTF8);
102 output_.Answer(s); 101 output_.Answer(s);
103 } 102 }
104 103
105 alreadySent_ = true; 104 alreadySent_ = true;
120 119
121 if (convertJsonToXml_ && 120 if (convertJsonToXml_ &&
122 contentType == MimeType_Json) 121 contentType == MimeType_Json)
123 { 122 {
124 Json::Value json; 123 Json::Value json;
125 Json::Reader reader; 124 if (Toolbox::ReadJson(json, buffer, length))
126 if (reader.parse(reinterpret_cast<const char*>(buffer),
127 reinterpret_cast<const char*>(buffer) + length, json))
128 { 125 {
129 AnswerJson(json); 126 AnswerJson(json);
130 } 127 }
131 else 128 else
132 { 129 {