From 480f1e45cce5b75ad2a3c4f8e9f0aca9f1a71fd8 Mon Sep 17 00:00:00 2001 From: woodser Date: Wed, 9 Oct 2019 10:51:04 -0400 Subject: [PATCH] add monero_utils::deserialize() --- src/utils/monero_utils.cpp | 7 +++++++ src/utils/monero_utils.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/utils/monero_utils.cpp b/src/utils/monero_utils.cpp index ee4c576..e586029 100644 --- a/src/utils/monero_utils.cpp +++ b/src/utils/monero_utils.cpp @@ -451,6 +451,13 @@ string monero_utils::serialize(const boost::property_tree::ptree& node) { return str.substr(0, str.size() - 1); // strip newline } +boost::property_tree::ptree monero_utils::deserialize(const string& json) { + std::istringstream iss = json.empty() ? std::istringstream() : std::istringstream(json); + boost::property_tree::ptree node; + boost::property_tree::read_json(iss, node); + return node; +} + boost::property_tree::ptree monero_utils::to_property_tree(const vector& strs) { boost::property_tree::ptree strsNode; for (const auto& str : strs) { diff --git a/src/utils/monero_utils.h b/src/utils/monero_utils.h index 9eacd79..2442002 100644 --- a/src/utils/monero_utils.h +++ b/src/utils/monero_utils.h @@ -84,6 +84,8 @@ namespace monero_utils string serialize(const boost::property_tree::ptree& node); + boost::property_tree::ptree deserialize(const string& json); + /** * Convert a Monero Core cryptonote::block to a block in this library's native model. *