Mercurial > hg > orthanc
comparison OrthancFramework/Sources/Toolbox.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 | 785a2713323e |
children | e8e95b80194f |
comparison
equal
deleted
inserted
replaced
4391:0c4ff5609548 | 4392:3af1d763763a |
---|---|
24 #include "Toolbox.h" | 24 #include "Toolbox.h" |
25 | 25 |
26 #include "Compatibility.h" | 26 #include "Compatibility.h" |
27 #include "OrthancException.h" | 27 #include "OrthancException.h" |
28 #include "Logging.h" | 28 #include "Logging.h" |
29 | |
30 #include <json/json.h> | |
29 | 31 |
30 #include <boost/algorithm/string/case_conv.hpp> | 32 #include <boost/algorithm/string/case_conv.hpp> |
31 #include <boost/algorithm/string/replace.hpp> | 33 #include <boost/algorithm/string/replace.hpp> |
32 #include <boost/lexical_cast.hpp> | 34 #include <boost/lexical_cast.hpp> |
33 #include <boost/regex.hpp> | 35 #include <boost/regex.hpp> |
2267 { | 2269 { |
2268 assert(0); | 2270 assert(0); |
2269 } | 2271 } |
2270 } | 2272 } |
2271 } | 2273 } |
2274 | |
2275 | |
2276 bool Toolbox::ReadJson(Json::Value& target, | |
2277 const std::string& source) | |
2278 { | |
2279 Json::Reader reader; | |
2280 return reader.parse(source, target); | |
2281 } | |
2282 | |
2283 | |
2284 bool Toolbox::ReadJson(Json::Value& target, | |
2285 const void* buffer, | |
2286 size_t size) | |
2287 { | |
2288 Json::Reader reader; | |
2289 return reader.parse(reinterpret_cast<const char*>(buffer), | |
2290 reinterpret_cast<const char*>(buffer) + size, target); | |
2291 } | |
2292 | |
2293 | |
2294 void Toolbox::WriteJson(std::string& target, | |
2295 const Json::Value& source, | |
2296 bool fast) | |
2297 { | |
2298 if (fast) | |
2299 { | |
2300 Json::FastWriter writer; | |
2301 target = writer.write(source); | |
2302 } | |
2303 else | |
2304 { | |
2305 Json::StyledWriter writer; | |
2306 target = writer.write(source); | |
2307 } | |
2308 } | |
2272 } | 2309 } |
2273 | 2310 |
2274 | 2311 |
2275 | 2312 |
2276 OrthancLinesIterator* OrthancLinesIterator_Create(const std::string& content) | 2313 OrthancLinesIterator* OrthancLinesIterator_Create(const std::string& content) |