Mercurial > hg > orthanc
comparison OrthancFramework/Sources/Toolbox.cpp @ 4394:f7104e9d044c
functions to read/write JSON in OrthancPluginCppWrapper.h
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 22 Dec 2020 08:11:37 +0100 |
parents | e8e95b80194f |
children | d07a65100a95 |
comparison
equal
deleted
inserted
replaced
4393:e8e95b80194f | 4394:f7104e9d044c |
---|---|
2334 } | 2334 } |
2335 #endif | 2335 #endif |
2336 } | 2336 } |
2337 | 2337 |
2338 | 2338 |
2339 void Toolbox::WriteJson(std::string& target, | 2339 void Toolbox::WriteFastJson(std::string& target, |
2340 const Json::Value& source, | 2340 const Json::Value& source) |
2341 bool fast) | |
2342 { | 2341 { |
2343 #if JSONCPP_USE_DEPRECATED == 1 | 2342 #if JSONCPP_USE_DEPRECATED == 1 |
2344 if (fast) | 2343 Json::FastWriter writer; |
2345 { | 2344 target = writer.write(source); |
2346 Json::FastWriter writer; | |
2347 target = writer.write(source); | |
2348 } | |
2349 else | |
2350 { | |
2351 Json::StyledWriter writer; | |
2352 target = writer.write(source); | |
2353 } | |
2354 #else | 2345 #else |
2355 if (fast) | 2346 Json::StreamWriterBuilder builder; |
2356 { | 2347 builder.settings_["indentation"] = ""; |
2357 Json::StreamWriterBuilder builder; | 2348 target = Json::writeString(builder, source); |
2358 builder.settings_["indentation"] = ""; | 2349 #endif |
2359 target = Json::writeString(builder, source); | 2350 } |
2360 } | 2351 |
2361 else | 2352 |
2362 { | 2353 void Toolbox::WriteStyledJson(std::string& target, |
2363 Json::StreamWriterBuilder builder; | 2354 const Json::Value& source) |
2364 builder.settings_["indentation"] = " "; | 2355 { |
2365 target = Json::writeString(builder, source); | 2356 #if JSONCPP_USE_DEPRECATED == 1 |
2366 } | 2357 Json::StyledWriter writer; |
2358 target = writer.write(source); | |
2359 #else | |
2360 Json::StreamWriterBuilder builder; | |
2361 builder.settings_["indentation"] = " "; | |
2362 target = Json::writeString(builder, source); | |
2367 #endif | 2363 #endif |
2368 } | 2364 } |
2369 } | 2365 } |
2370 | 2366 |
2371 | 2367 |