Mercurial > hg > orthanc-wsi
comparison Resources/Orthanc/Stone/IOrthancConnection.cpp @ 212:f1ea48f92d66
sync
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 22 Dec 2020 09:19:43 +0100 |
parents | b0bd22077cd8 |
children | 1e864138f0da |
comparison
equal
deleted
inserted
replaced
211:7459819f3176 | 212:f1ea48f92d66 |
---|---|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
4 * Department, University Hospital of Liege, Belgium | 4 * Department, University Hospital of Liege, Belgium |
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium | 5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
6 * | 6 * |
7 * This program is free software: you can redistribute it and/or | 7 * This program is free software: you can redistribute it and/or |
8 * modify it under the terms of the GNU Affero General Public License | 8 * modify it under the terms of the GNU Lesser General Public License |
9 * as published by the Free Software Foundation, either version 3 of | 9 * as published by the Free Software Foundation, either version 3 of |
10 * the License, or (at your option) any later version. | 10 * the License, or (at your option) any later version. |
11 * | 11 * |
12 * This program is distributed in the hope that it will be useful, but | 12 * This program is distributed in the hope that it will be useful, but |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Affero General Public License for more details. | 15 * Lesser General Public License for more details. |
16 * | 16 * |
17 * You should have received a copy of the GNU Affero General Public License | 17 * You should have received a copy of the GNU Lesser General Public |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 * License along with this program. If not, see |
19 * <http://www.gnu.org/licenses/>. | |
19 **/ | 20 **/ |
20 | 21 |
21 | 22 |
22 #include "IOrthancConnection.h" | 23 #include "IOrthancConnection.h" |
23 | 24 |
24 #include <OrthancException.h> | 25 #include <OrthancException.h> |
25 | 26 #include <Toolbox.h> |
26 #include <json/reader.h> | |
27 | 27 |
28 namespace OrthancStone | 28 namespace OrthancStone |
29 { | 29 { |
30 void IOrthancConnection::ParseJson(Json::Value& result, | 30 void IOrthancConnection::ParseJson(Json::Value& result, |
31 const std::string& content) | 31 const std::string& content) |
32 { | 32 { |
33 Json::Reader reader; | 33 if (!Orthanc::Toolbox::ReadJson(result, content)) |
34 | |
35 if (!reader.parse(content, result)) | |
36 { | 34 { |
37 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | 35 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
38 } | 36 } |
39 } | 37 } |
40 | 38 |
41 | 39 |
42 void IOrthancConnection::ParseJson(Json::Value& result, | 40 void IOrthancConnection::ParseJson(Json::Value& result, |
43 const void* content, | 41 const void* content, |
44 size_t size) | 42 size_t size) |
45 { | 43 { |
46 Json::Reader reader; | 44 if (!Orthanc::Toolbox::ReadJson(result, content, size)) |
47 | |
48 if (!reader.parse(reinterpret_cast<const char*>(content), | |
49 reinterpret_cast<const char*>(content) + size, result)) | |
50 { | 45 { |
51 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | 46 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
52 } | 47 } |
53 } | 48 } |
54 | 49 |