monero_utils::deserialize() accepts target node as param

This commit is contained in:
woodser
2019-10-09 11:00:11 -04:00
parent eaac2199a5
commit 65d60d35b9
2 changed files with 7 additions and 5 deletions
+6 -4
View File
@@ -452,11 +452,13 @@ string monero_utils::serialize(const boost::property_tree::ptree& node) {
}
// TODO: switch deserializes in this utils class to use this deserialize util
boost::property_tree::ptree monero_utils::deserialize(const string& json) {
void monero_utils::deserialize(const string& json, boost::property_tree::ptree& root) {
std::istringstream iss = json.empty() ? std::istringstream() : std::istringstream(json);
boost::property_tree::ptree node;
boost::property_tree::read_json(iss, node);
return node;
try {
boost::property_tree::read_json(iss, root);
} catch (std::exception const& e) {
throw runtime_error("Invalid JSON");
}
}
boost::property_tree::ptree monero_utils::to_property_tree(const vector<string>& strs) {
+1 -1
View File
@@ -84,7 +84,7 @@ namespace monero_utils
string serialize(const boost::property_tree::ptree& node);
boost::property_tree::ptree deserialize(const string& json);
void deserialize(const string& json, boost::property_tree::ptree& root);
/**
* Convert a Monero Core cryptonote::block to a block in this library's native model.