aboutsummaryrefslogtreecommitdiff
path: root/src/serialization/json_object.cpp
diff options
context:
space:
mode:
authorAlexander Blair <snipa@jagtech.io>2020-03-12 01:13:48 -0700
committerAlexander Blair <snipa@jagtech.io>2020-03-12 01:13:49 -0700
commit820ab9fdea6ede11aced3726f3998558f8677ad6 (patch)
tree2b8df276eff7637e4c9dd20f5acd9a55e12deea7 /src/serialization/json_object.cpp
parentMerge pull request #6268 (diff)
parentVarious improvements to the ZMQ JSON-RPC handling: (diff)
downloadmonero-820ab9fdea6ede11aced3726f3998558f8677ad6.tar.xz
Merge pull request #6273
0f78b06e Various improvements to the ZMQ JSON-RPC handling: (Lee Clagett)
Diffstat (limited to 'src/serialization/json_object.cpp')
-rw-r--r--src/serialization/json_object.cpp621
1 files changed, 340 insertions, 281 deletions
diff --git a/src/serialization/json_object.cpp b/src/serialization/json_object.cpp
index ea67209dc..e98ba0483 100644
--- a/src/serialization/json_object.cpp
+++ b/src/serialization/json_object.cpp
@@ -109,9 +109,14 @@ namespace
}
}
-void toJsonValue(rapidjson::Document& doc, const std::string& i, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const rapidjson::Value& src)
{
- val = rapidjson::Value(i.c_str(), doc.GetAllocator());
+ src.Accept(dest);
+}
+
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const boost::string_ref i)
+{
+ dest.String(i.data(), i.size());
}
void fromJsonValue(const rapidjson::Value& val, std::string& str)
@@ -124,9 +129,9 @@ void fromJsonValue(const rapidjson::Value& val, std::string& str)
str = val.GetString();
}
-void toJsonValue(rapidjson::Document& doc, bool i, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, bool i)
{
- val.SetBool(i);
+ dest.Bool(i);
}
void fromJsonValue(const rapidjson::Value& val, bool& b)
@@ -163,9 +168,9 @@ void fromJsonValue(const rapidjson::Value& val, short& i)
to_int(val, i);
}
-void toJsonValue(rapidjson::Document& doc, const unsigned int i, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const unsigned int i)
{
- val = rapidjson::Value(i);
+ dest.Uint(i);
}
void fromJsonValue(const rapidjson::Value& val, unsigned int& i)
@@ -173,9 +178,9 @@ void fromJsonValue(const rapidjson::Value& val, unsigned int& i)
to_uint(val, i);
}
-void toJsonValue(rapidjson::Document& doc, const int i, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const int i)
{
- val = rapidjson::Value(i);
+ dest.Int(i);
}
void fromJsonValue(const rapidjson::Value& val, int& i)
@@ -183,10 +188,10 @@ void fromJsonValue(const rapidjson::Value& val, int& i)
to_int(val, i);
}
-void toJsonValue(rapidjson::Document& doc, const unsigned long long i, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const unsigned long long i)
{
- static_assert(!precision_loss<unsigned long long, std::uint64_t>(), "precision loss");
- val = rapidjson::Value(std::uint64_t(i));
+ static_assert(std::numeric_limits<unsigned long long>::max() <= std::numeric_limits<std::uint64_t>::max(), "bad uint64 conversion");
+ dest.Uint64(i);
}
void fromJsonValue(const rapidjson::Value& val, unsigned long long& i)
@@ -194,10 +199,11 @@ void fromJsonValue(const rapidjson::Value& val, unsigned long long& i)
to_uint64(val, i);
}
-void toJsonValue(rapidjson::Document& doc, const long long i, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const long long i)
{
- static_assert(!precision_loss<long long, std::int64_t>(), "precision loss");
- val = rapidjson::Value(std::int64_t(i));
+ static_assert(std::numeric_limits<std::uint64_t>::min() <= std::numeric_limits<long long>::min(), "bad int64 conversion");
+ static_assert(std::numeric_limits<long long>::max() <= std::numeric_limits<std::uint64_t>::max(), "bad int64 conversion");
+ dest.Int64(i);
}
void fromJsonValue(const rapidjson::Value& val, long long& i)
@@ -215,17 +221,19 @@ void fromJsonValue(const rapidjson::Value& val, long& i)
to_int64(val, i);
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::transaction& tx, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::transaction& tx)
{
- val.SetObject();
+ dest.StartObject();
- INSERT_INTO_JSON_OBJECT(val, doc, version, tx.version);
- INSERT_INTO_JSON_OBJECT(val, doc, unlock_time, tx.unlock_time);
- INSERT_INTO_JSON_OBJECT(val, doc, inputs, tx.vin);
- INSERT_INTO_JSON_OBJECT(val, doc, outputs, tx.vout);
- INSERT_INTO_JSON_OBJECT(val, doc, extra, tx.extra);
- INSERT_INTO_JSON_OBJECT(val, doc, signatures, tx.signatures);
- INSERT_INTO_JSON_OBJECT(val, doc, ringct, tx.rct_signatures);
+ INSERT_INTO_JSON_OBJECT(dest, version, tx.version);
+ INSERT_INTO_JSON_OBJECT(dest, unlock_time, tx.unlock_time);
+ INSERT_INTO_JSON_OBJECT(dest, inputs, tx.vin);
+ INSERT_INTO_JSON_OBJECT(dest, outputs, tx.vout);
+ INSERT_INTO_JSON_OBJECT(dest, extra, tx.extra);
+ INSERT_INTO_JSON_OBJECT(dest, signatures, tx.signatures);
+ INSERT_INTO_JSON_OBJECT(dest, ringct, tx.rct_signatures);
+
+ dest.EndObject();
}
@@ -245,17 +253,19 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::transaction& tx)
GET_FROM_JSON_OBJECT(val, tx.rct_signatures, ringct);
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::block& b, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::block& b)
{
- val.SetObject();
+ dest.StartObject();
+
+ INSERT_INTO_JSON_OBJECT(dest, major_version, b.major_version);
+ INSERT_INTO_JSON_OBJECT(dest, minor_version, b.minor_version);
+ INSERT_INTO_JSON_OBJECT(dest, timestamp, b.timestamp);
+ INSERT_INTO_JSON_OBJECT(dest, prev_id, b.prev_id);
+ INSERT_INTO_JSON_OBJECT(dest, nonce, b.nonce);
+ INSERT_INTO_JSON_OBJECT(dest, miner_tx, b.miner_tx);
+ INSERT_INTO_JSON_OBJECT(dest, tx_hashes, b.tx_hashes);
- INSERT_INTO_JSON_OBJECT(val, doc, major_version, b.major_version);
- INSERT_INTO_JSON_OBJECT(val, doc, minor_version, b.minor_version);
- INSERT_INTO_JSON_OBJECT(val, doc, timestamp, b.timestamp);
- INSERT_INTO_JSON_OBJECT(val, doc, prev_id, b.prev_id);
- INSERT_INTO_JSON_OBJECT(val, doc, nonce, b.nonce);
- INSERT_INTO_JSON_OBJECT(val, doc, miner_tx, b.miner_tx);
- INSERT_INTO_JSON_OBJECT(val, doc, tx_hashes, b.tx_hashes);
+ dest.EndObject();
}
@@ -275,35 +285,34 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::block& b)
GET_FROM_JSON_OBJECT(val, b.tx_hashes, tx_hashes);
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::txin_v& txin, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::txin_v& txin)
{
- val.SetObject();
-
+ dest.StartObject();
struct add_input
{
using result_type = void;
- rapidjson::Document& doc;
- rapidjson::Value& val;
+ rapidjson::Writer<rapidjson::StringBuffer>& dest;
void operator()(cryptonote::txin_to_key const& input) const
{
- INSERT_INTO_JSON_OBJECT(val, doc, to_key, input);
+ INSERT_INTO_JSON_OBJECT(dest, to_key, input);
}
void operator()(cryptonote::txin_gen const& input) const
{
- INSERT_INTO_JSON_OBJECT(val, doc, gen, input);
+ INSERT_INTO_JSON_OBJECT(dest, gen, input);
}
void operator()(cryptonote::txin_to_script const& input) const
{
- INSERT_INTO_JSON_OBJECT(val, doc, to_script, input);
+ INSERT_INTO_JSON_OBJECT(dest, to_script, input);
}
void operator()(cryptonote::txin_to_scripthash const& input) const
{
- INSERT_INTO_JSON_OBJECT(val, doc, to_scripthash, input);
+ INSERT_INTO_JSON_OBJECT(dest, to_scripthash, input);
}
};
- boost::apply_visitor(add_input{doc, val}, txin);
+ boost::apply_visitor(add_input{dest}, txin);
+ dest.EndObject();
}
@@ -348,13 +357,14 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::txin_v& txin)
}
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::txin_gen& txin, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::txin_gen& txin)
{
- val.SetObject();
+ dest.StartObject();
- INSERT_INTO_JSON_OBJECT(val, doc, height, txin.height);
-}
+ INSERT_INTO_JSON_OBJECT(dest, height, txin.height);
+ dest.EndObject();
+}
void fromJsonValue(const rapidjson::Value& val, cryptonote::txin_gen& txin)
{
@@ -366,13 +376,15 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::txin_gen& txin)
GET_FROM_JSON_OBJECT(val, txin.height, height);
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::txin_to_script& txin, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::txin_to_script& txin)
{
- val.SetObject();
+ dest.StartObject();
+
+ INSERT_INTO_JSON_OBJECT(dest, prev, txin.prev);
+ INSERT_INTO_JSON_OBJECT(dest, prevout, txin.prevout);
+ INSERT_INTO_JSON_OBJECT(dest, sigset, txin.sigset);
- INSERT_INTO_JSON_OBJECT(val, doc, prev, txin.prev);
- INSERT_INTO_JSON_OBJECT(val, doc, prevout, txin.prevout);
- INSERT_INTO_JSON_OBJECT(val, doc, sigset, txin.sigset);
+ dest.EndObject();
}
@@ -388,14 +400,17 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::txin_to_script& txin
GET_FROM_JSON_OBJECT(val, txin.sigset, sigset);
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::txin_to_scripthash& txin, rapidjson::Value& val)
+
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::txin_to_scripthash& txin)
{
- val.SetObject();
+ dest.StartObject();
+
+ INSERT_INTO_JSON_OBJECT(dest, prev, txin.prev);
+ INSERT_INTO_JSON_OBJECT(dest, prevout, txin.prevout);
+ INSERT_INTO_JSON_OBJECT(dest, script, txin.script);
+ INSERT_INTO_JSON_OBJECT(dest, sigset, txin.sigset);
- INSERT_INTO_JSON_OBJECT(val, doc, prev, txin.prev);
- INSERT_INTO_JSON_OBJECT(val, doc, prevout, txin.prevout);
- INSERT_INTO_JSON_OBJECT(val, doc, script, txin.script);
- INSERT_INTO_JSON_OBJECT(val, doc, sigset, txin.sigset);
+ dest.EndObject();
}
@@ -412,15 +427,16 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::txin_to_scripthash&
GET_FROM_JSON_OBJECT(val, txin.sigset, sigset);
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::txin_to_key& txin, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::txin_to_key& txin)
{
- val.SetObject();
+ dest.StartObject();
- INSERT_INTO_JSON_OBJECT(val, doc, amount, txin.amount);
- INSERT_INTO_JSON_OBJECT(val, doc, key_offsets, txin.key_offsets);
- INSERT_INTO_JSON_OBJECT(val, doc, key_image, txin.k_image);
-}
+ INSERT_INTO_JSON_OBJECT(dest, amount, txin.amount);
+ INSERT_INTO_JSON_OBJECT(dest, key_offsets, txin.key_offsets);
+ INSERT_INTO_JSON_OBJECT(dest, key_image, txin.k_image);
+ dest.EndObject();
+}
void fromJsonValue(const rapidjson::Value& val, cryptonote::txin_to_key& txin)
{
@@ -434,14 +450,16 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::txin_to_key& txin)
GET_FROM_JSON_OBJECT(val, txin.k_image, key_image);
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::txout_to_script& txout, rapidjson::Value& val)
+
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::txout_to_script& txout)
{
- val.SetObject();
+ dest.StartObject();
- INSERT_INTO_JSON_OBJECT(val, doc, keys, txout.keys);
- INSERT_INTO_JSON_OBJECT(val, doc, script, txout.script);
-}
+ INSERT_INTO_JSON_OBJECT(dest, keys, txout.keys);
+ INSERT_INTO_JSON_OBJECT(dest, script, txout.script);
+ dest.EndObject();
+}
void fromJsonValue(const rapidjson::Value& val, cryptonote::txout_to_script& txout)
{
@@ -454,13 +472,15 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::txout_to_script& txo
GET_FROM_JSON_OBJECT(val, txout.script, script);
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::txout_to_scripthash& txout, rapidjson::Value& val)
+
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::txout_to_scripthash& txout)
{
- val.SetObject();
+ dest.StartObject();
- INSERT_INTO_JSON_OBJECT(val, doc, hash, txout.hash);
-}
+ INSERT_INTO_JSON_OBJECT(dest, hash, txout.hash);
+ dest.EndObject();
+}
void fromJsonValue(const rapidjson::Value& val, cryptonote::txout_to_scripthash& txout)
{
@@ -472,13 +492,15 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::txout_to_scripthash&
GET_FROM_JSON_OBJECT(val, txout.hash, hash);
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::txout_to_key& txout, rapidjson::Value& val)
+
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::txout_to_key& txout)
{
- val.SetObject();
+ dest.StartObject();
- INSERT_INTO_JSON_OBJECT(val, doc, key, txout.key);
-}
+ INSERT_INTO_JSON_OBJECT(dest, key, txout.key);
+ dest.EndObject();
+}
void fromJsonValue(const rapidjson::Value& val, cryptonote::txout_to_key& txout)
{
@@ -490,33 +512,32 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::txout_to_key& txout)
GET_FROM_JSON_OBJECT(val, txout.key, key);
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::tx_out& txout, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::tx_out& txout)
{
- val.SetObject();
-
- INSERT_INTO_JSON_OBJECT(val, doc, amount, txout.amount);
+ dest.StartObject();
+ INSERT_INTO_JSON_OBJECT(dest, amount, txout.amount);
struct add_output
{
using result_type = void;
- rapidjson::Document& doc;
- rapidjson::Value& val;
+ rapidjson::Writer<rapidjson::StringBuffer>& dest;
void operator()(cryptonote::txout_to_key const& output) const
{
- INSERT_INTO_JSON_OBJECT(val, doc, to_key, output);
+ INSERT_INTO_JSON_OBJECT(dest, to_key, output);
}
void operator()(cryptonote::txout_to_script const& output) const
{
- INSERT_INTO_JSON_OBJECT(val, doc, to_script, output);
+ INSERT_INTO_JSON_OBJECT(dest, to_script, output);
}
void operator()(cryptonote::txout_to_scripthash const& output) const
{
- INSERT_INTO_JSON_OBJECT(val, doc, to_scripthash, output);
+ INSERT_INTO_JSON_OBJECT(dest, to_scripthash, output);
}
};
- boost::apply_visitor(add_output{doc, val}, txout.target);
+ boost::apply_visitor(add_output{dest}, txout.target);
+ dest.EndObject();
}
void fromJsonValue(const rapidjson::Value& val, cryptonote::tx_out& txout)
@@ -559,37 +580,39 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::tx_out& txout)
}
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::connection_info& info, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::connection_info& info)
{
- val.SetObject();
+ dest.StartObject();
+
+ INSERT_INTO_JSON_OBJECT(dest, incoming, info.incoming);
+ INSERT_INTO_JSON_OBJECT(dest, localhost, info.localhost);
+ INSERT_INTO_JSON_OBJECT(dest, local_ip, info.local_ip);
+ INSERT_INTO_JSON_OBJECT(dest, address_type, info.address_type);
- INSERT_INTO_JSON_OBJECT(val, doc, incoming, info.incoming);
- INSERT_INTO_JSON_OBJECT(val, doc, localhost, info.localhost);
- INSERT_INTO_JSON_OBJECT(val, doc, local_ip, info.local_ip);
- INSERT_INTO_JSON_OBJECT(val, doc, address_type, info.address_type);
+ INSERT_INTO_JSON_OBJECT(dest, ip, info.ip);
+ INSERT_INTO_JSON_OBJECT(dest, port, info.port);
+ INSERT_INTO_JSON_OBJECT(dest, rpc_port, info.rpc_port);
+ INSERT_INTO_JSON_OBJECT(dest, rpc_credits_per_hash, info.rpc_credits_per_hash);
- INSERT_INTO_JSON_OBJECT(val, doc, ip, info.ip);
- INSERT_INTO_JSON_OBJECT(val, doc, port, info.port);
- INSERT_INTO_JSON_OBJECT(val, doc, rpc_port, info.rpc_port);
- INSERT_INTO_JSON_OBJECT(val, doc, rpc_credits_per_hash, info.rpc_credits_per_hash);
+ INSERT_INTO_JSON_OBJECT(dest, peer_id, info.peer_id);
- INSERT_INTO_JSON_OBJECT(val, doc, peer_id, info.peer_id);
+ INSERT_INTO_JSON_OBJECT(dest, recv_count, info.recv_count);
+ INSERT_INTO_JSON_OBJECT(dest, recv_idle_time, info.recv_idle_time);
- INSERT_INTO_JSON_OBJECT(val, doc, recv_count, info.recv_count);
- INSERT_INTO_JSON_OBJECT(val, doc, recv_idle_time, info.recv_idle_time);
+ INSERT_INTO_JSON_OBJECT(dest, send_count, info.send_count);
+ INSERT_INTO_JSON_OBJECT(dest, send_idle_time, info.send_idle_time);
- INSERT_INTO_JSON_OBJECT(val, doc, send_count, info.send_count);
- INSERT_INTO_JSON_OBJECT(val, doc, send_idle_time, info.send_idle_time);
+ INSERT_INTO_JSON_OBJECT(dest, state, info.state);
- INSERT_INTO_JSON_OBJECT(val, doc, state, info.state);
+ INSERT_INTO_JSON_OBJECT(dest, live_time, info.live_time);
- INSERT_INTO_JSON_OBJECT(val, doc, live_time, info.live_time);
+ INSERT_INTO_JSON_OBJECT(dest, avg_download, info.avg_download);
+ INSERT_INTO_JSON_OBJECT(dest, current_download, info.current_download);
- INSERT_INTO_JSON_OBJECT(val, doc, avg_download, info.avg_download);
- INSERT_INTO_JSON_OBJECT(val, doc, current_download, info.current_download);
+ INSERT_INTO_JSON_OBJECT(dest, avg_upload, info.avg_upload);
+ INSERT_INTO_JSON_OBJECT(dest, current_upload, info.current_upload);
- INSERT_INTO_JSON_OBJECT(val, doc, avg_upload, info.avg_upload);
- INSERT_INTO_JSON_OBJECT(val, doc, current_upload, info.current_upload);
+ dest.EndObject();
}
@@ -629,12 +652,14 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::connection_info& inf
GET_FROM_JSON_OBJECT(val, info.current_upload, current_upload);
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::tx_blob_entry& tx, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::tx_blob_entry& tx)
{
- val.SetObject();
+ dest.StartObject();
+
+ INSERT_INTO_JSON_OBJECT(dest, blob, tx.blob);
+ INSERT_INTO_JSON_OBJECT(dest, prunable_hash, tx.prunable_hash);
- INSERT_INTO_JSON_OBJECT(val, doc, blob, tx.blob);
- INSERT_INTO_JSON_OBJECT(val, doc, prunable_hash, tx.prunable_hash);
+ dest.EndObject();
}
void fromJsonValue(const rapidjson::Value& val, cryptonote::tx_blob_entry& tx)
@@ -648,12 +673,14 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::tx_blob_entry& tx)
GET_FROM_JSON_OBJECT(val, tx.prunable_hash, prunable_hash);
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::block_complete_entry& blk, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::block_complete_entry& blk)
{
- val.SetObject();
+ dest.StartObject();
- INSERT_INTO_JSON_OBJECT(val, doc, block, blk.block);
- INSERT_INTO_JSON_OBJECT(val, doc, transactions, blk.txs);
+ INSERT_INTO_JSON_OBJECT(dest, block, blk.block);
+ INSERT_INTO_JSON_OBJECT(dest, transactions, blk.txs);
+
+ dest.EndObject();
}
@@ -668,12 +695,14 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::block_complete_entry
GET_FROM_JSON_OBJECT(val, blk.txs, transactions);
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::rpc::block_with_transactions& blk, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::rpc::block_with_transactions& blk)
{
- val.SetObject();
+ dest.StartObject();
+
+ INSERT_INTO_JSON_OBJECT(dest, block, blk.block);
+ INSERT_INTO_JSON_OBJECT(dest, transactions, blk.transactions);
- INSERT_INTO_JSON_OBJECT(val, doc, block, blk.block);
- INSERT_INTO_JSON_OBJECT(val, doc, transactions, blk.transactions);
+ dest.EndObject();
}
@@ -688,13 +717,15 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::rpc::block_with_tran
GET_FROM_JSON_OBJECT(val, blk.transactions, transactions);
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::rpc::transaction_info& tx_info, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::rpc::transaction_info& tx_info)
{
- val.SetObject();
+ dest.StartObject();
+
+ INSERT_INTO_JSON_OBJECT(dest, height, tx_info.height);
+ INSERT_INTO_JSON_OBJECT(dest, in_pool, tx_info.in_pool);
+ INSERT_INTO_JSON_OBJECT(dest, transaction, tx_info.transaction);
- INSERT_INTO_JSON_OBJECT(val, doc, height, tx_info.height);
- INSERT_INTO_JSON_OBJECT(val, doc, in_pool, tx_info.in_pool);
- INSERT_INTO_JSON_OBJECT(val, doc, transaction, tx_info.transaction);
+ dest.EndObject();
}
@@ -710,12 +741,14 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::rpc::transaction_inf
GET_FROM_JSON_OBJECT(val, tx_info.transaction, transaction);
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::rpc::output_key_and_amount_index& out, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::rpc::output_key_and_amount_index& out)
{
- val.SetObject();
+ dest.StartObject();
- INSERT_INTO_JSON_OBJECT(val, doc, amount_index, out.amount_index);
- INSERT_INTO_JSON_OBJECT(val, doc, key, out.key);
+ INSERT_INTO_JSON_OBJECT(dest, amount_index, out.amount_index);
+ INSERT_INTO_JSON_OBJECT(dest, key, out.key);
+
+ dest.EndObject();
}
@@ -730,12 +763,14 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::rpc::output_key_and_
GET_FROM_JSON_OBJECT(val, out.key, key);
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::rpc::amount_with_random_outputs& out, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::rpc::amount_with_random_outputs& out)
{
- val.SetObject();
+ dest.StartObject();
+
+ INSERT_INTO_JSON_OBJECT(dest, amount, out.amount);
+ INSERT_INTO_JSON_OBJECT(dest, outputs, out.outputs);
- INSERT_INTO_JSON_OBJECT(val, doc, amount, out.amount);
- INSERT_INTO_JSON_OBJECT(val, doc, outputs, out.outputs);
+ dest.EndObject();
}
@@ -750,17 +785,19 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::rpc::amount_with_ran
GET_FROM_JSON_OBJECT(val, out.outputs, outputs);
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::rpc::peer& peer, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::rpc::peer& peer)
{
- val.SetObject();
+ dest.StartObject();
+
+ INSERT_INTO_JSON_OBJECT(dest, id, peer.id);
+ INSERT_INTO_JSON_OBJECT(dest, ip, peer.ip);
+ INSERT_INTO_JSON_OBJECT(dest, port, peer.port);
+ INSERT_INTO_JSON_OBJECT(dest, rpc_port, peer.rpc_port);
+ INSERT_INTO_JSON_OBJECT(dest, rpc_credits_per_hash, peer.rpc_credits_per_hash);
+ INSERT_INTO_JSON_OBJECT(dest, last_seen, peer.last_seen);
+ INSERT_INTO_JSON_OBJECT(dest, pruning_seed, peer.pruning_seed);
- INSERT_INTO_JSON_OBJECT(val, doc, id, peer.id);
- INSERT_INTO_JSON_OBJECT(val, doc, ip, peer.ip);
- INSERT_INTO_JSON_OBJECT(val, doc, port, peer.port);
- INSERT_INTO_JSON_OBJECT(val, doc, rpc_port, peer.rpc_port);
- INSERT_INTO_JSON_OBJECT(val, doc, rpc_credits_per_hash, peer.rpc_credits_per_hash);
- INSERT_INTO_JSON_OBJECT(val, doc, last_seen, peer.last_seen);
- INSERT_INTO_JSON_OBJECT(val, doc, pruning_seed, peer.pruning_seed);
+ dest.EndObject();
}
@@ -780,25 +817,27 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::rpc::peer& peer)
GET_FROM_JSON_OBJECT(val, peer.pruning_seed, pruning_seed);
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::rpc::tx_in_pool& tx, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::rpc::tx_in_pool& tx)
{
- val.SetObject();
+ dest.StartObject();
- INSERT_INTO_JSON_OBJECT(val, doc, tx, tx.tx);
- INSERT_INTO_JSON_OBJECT(val, doc, tx_hash, tx.tx_hash);
- INSERT_INTO_JSON_OBJECT(val, doc, blob_size, tx.blob_size);
- INSERT_INTO_JSON_OBJECT(val, doc, weight, tx.weight);
- INSERT_INTO_JSON_OBJECT(val, doc, fee, tx.fee);
- INSERT_INTO_JSON_OBJECT(val, doc, max_used_block_hash, tx.max_used_block_hash);
- INSERT_INTO_JSON_OBJECT(val, doc, max_used_block_height, tx.max_used_block_height);
- INSERT_INTO_JSON_OBJECT(val, doc, kept_by_block, tx.kept_by_block);
- INSERT_INTO_JSON_OBJECT(val, doc, last_failed_block_hash, tx.last_failed_block_hash);
- INSERT_INTO_JSON_OBJECT(val, doc, last_failed_block_height, tx.last_failed_block_height);
- INSERT_INTO_JSON_OBJECT(val, doc, receive_time, tx.receive_time);
- INSERT_INTO_JSON_OBJECT(val, doc, last_relayed_time, tx.last_relayed_time);
- INSERT_INTO_JSON_OBJECT(val, doc, relayed, tx.relayed);
- INSERT_INTO_JSON_OBJECT(val, doc, do_not_relay, tx.do_not_relay);
- INSERT_INTO_JSON_OBJECT(val, doc, double_spend_seen, tx.double_spend_seen);
+ INSERT_INTO_JSON_OBJECT(dest, tx, tx.tx);
+ INSERT_INTO_JSON_OBJECT(dest, tx_hash, tx.tx_hash);
+ INSERT_INTO_JSON_OBJECT(dest, blob_size, tx.blob_size);
+ INSERT_INTO_JSON_OBJECT(dest, weight, tx.weight);
+ INSERT_INTO_JSON_OBJECT(dest, fee, tx.fee);
+ INSERT_INTO_JSON_OBJECT(dest, max_used_block_hash, tx.max_used_block_hash);
+ INSERT_INTO_JSON_OBJECT(dest, max_used_block_height, tx.max_used_block_height);
+ INSERT_INTO_JSON_OBJECT(dest, kept_by_block, tx.kept_by_block);
+ INSERT_INTO_JSON_OBJECT(dest, last_failed_block_hash, tx.last_failed_block_hash);
+ INSERT_INTO_JSON_OBJECT(dest, last_failed_block_height, tx.last_failed_block_height);
+ INSERT_INTO_JSON_OBJECT(dest, receive_time, tx.receive_time);
+ INSERT_INTO_JSON_OBJECT(dest, last_relayed_time, tx.last_relayed_time);
+ INSERT_INTO_JSON_OBJECT(dest, relayed, tx.relayed);
+ INSERT_INTO_JSON_OBJECT(dest, do_not_relay, tx.do_not_relay);
+ INSERT_INTO_JSON_OBJECT(dest, double_spend_seen, tx.double_spend_seen);
+
+ dest.EndObject();
}
@@ -825,18 +864,20 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::rpc::tx_in_pool& tx)
GET_FROM_JSON_OBJECT(val, tx.double_spend_seen, double_spend_seen);
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::rpc::hard_fork_info& info, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::rpc::hard_fork_info& info)
{
- val.SetObject();
+ dest.StartObject();
+
+ INSERT_INTO_JSON_OBJECT(dest, version, info.version);
+ INSERT_INTO_JSON_OBJECT(dest, enabled, info.enabled);
+ INSERT_INTO_JSON_OBJECT(dest, window, info.window);
+ INSERT_INTO_JSON_OBJECT(dest, votes, info.votes);
+ INSERT_INTO_JSON_OBJECT(dest, threshold, info.threshold);
+ INSERT_INTO_JSON_OBJECT(dest, voting, info.voting);
+ INSERT_INTO_JSON_OBJECT(dest, state, info.state);
+ INSERT_INTO_JSON_OBJECT(dest, earliest_height, info.earliest_height);
- INSERT_INTO_JSON_OBJECT(val, doc, version, info.version);
- INSERT_INTO_JSON_OBJECT(val, doc, enabled, info.enabled);
- INSERT_INTO_JSON_OBJECT(val, doc, window, info.window);
- INSERT_INTO_JSON_OBJECT(val, doc, votes, info.votes);
- INSERT_INTO_JSON_OBJECT(val, doc, threshold, info.threshold);
- INSERT_INTO_JSON_OBJECT(val, doc, voting, info.voting);
- INSERT_INTO_JSON_OBJECT(val, doc, state, info.state);
- INSERT_INTO_JSON_OBJECT(val, doc, earliest_height, info.earliest_height);
+ dest.EndObject();
}
@@ -857,14 +898,16 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::rpc::hard_fork_info&
GET_FROM_JSON_OBJECT(val, info.earliest_height, earliest_height);
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::rpc::output_amount_count& out, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::rpc::output_amount_count& out)
{
- val.SetObject();
+ dest.StartObject();
- INSERT_INTO_JSON_OBJECT(val, doc, amount, out.amount);
- INSERT_INTO_JSON_OBJECT(val, doc, total_count, out.total_count);
- INSERT_INTO_JSON_OBJECT(val, doc, unlocked_count, out.unlocked_count);
- INSERT_INTO_JSON_OBJECT(val, doc, recent_count, out.recent_count);
+ INSERT_INTO_JSON_OBJECT(dest, amount, out.amount);
+ INSERT_INTO_JSON_OBJECT(dest, total_count, out.total_count);
+ INSERT_INTO_JSON_OBJECT(dest, unlocked_count, out.unlocked_count);
+ INSERT_INTO_JSON_OBJECT(dest, recent_count, out.recent_count);
+
+ dest.EndObject();
}
@@ -881,12 +924,14 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::rpc::output_amount_c
GET_FROM_JSON_OBJECT(val, out.recent_count, recent_count);
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::rpc::output_amount_and_index& out, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::rpc::output_amount_and_index& out)
{
- val.SetObject();
+ dest.StartObject();
+
+ INSERT_INTO_JSON_OBJECT(dest, amount, out.amount);
+ INSERT_INTO_JSON_OBJECT(dest, index, out.index);
- INSERT_INTO_JSON_OBJECT(val, doc, amount, out.amount);
- INSERT_INTO_JSON_OBJECT(val, doc, index, out.index);
+ dest.EndObject();
}
@@ -901,13 +946,15 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::rpc::output_amount_a
GET_FROM_JSON_OBJECT(val, out.index, index);
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::rpc::output_key_mask_unlocked& out, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::rpc::output_key_mask_unlocked& out)
{
- val.SetObject();
+ dest.StartObject();
+
+ INSERT_INTO_JSON_OBJECT(dest, key, out.key);
+ INSERT_INTO_JSON_OBJECT(dest, mask, out.mask);
+ INSERT_INTO_JSON_OBJECT(dest, unlocked, out.unlocked);
- INSERT_INTO_JSON_OBJECT(val, doc, key, out.key);
- INSERT_INTO_JSON_OBJECT(val, doc, mask, out.mask);
- INSERT_INTO_JSON_OBJECT(val, doc, unlocked, out.unlocked);
+ dest.EndObject();
}
void fromJsonValue(const rapidjson::Value& val, cryptonote::rpc::output_key_mask_unlocked& out)
@@ -922,13 +969,15 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::rpc::output_key_mask
GET_FROM_JSON_OBJECT(val, out.unlocked, unlocked);
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::rpc::error& err, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::rpc::error& err)
{
- val.SetObject();
+ dest.StartObject();
- INSERT_INTO_JSON_OBJECT(val, doc, code, err.code);
- INSERT_INTO_JSON_OBJECT(val, doc, error_str, err.error_str);
- INSERT_INTO_JSON_OBJECT(val, doc, message, err.message);
+ INSERT_INTO_JSON_OBJECT(dest, code, err.code);
+ INSERT_INTO_JSON_OBJECT(dest, error_str, err.error_str);
+ INSERT_INTO_JSON_OBJECT(dest, message, err.message);
+
+ dest.EndObject();
}
void fromJsonValue(const rapidjson::Value& val, cryptonote::rpc::error& error)
@@ -943,20 +992,22 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::rpc::error& error)
GET_FROM_JSON_OBJECT(val, error.message, message);
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::rpc::BlockHeaderResponse& response, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::rpc::BlockHeaderResponse& response)
{
- val.SetObject();
+ dest.StartObject();
+
+ INSERT_INTO_JSON_OBJECT(dest, major_version, response.major_version);
+ INSERT_INTO_JSON_OBJECT(dest, minor_version, response.minor_version);
+ INSERT_INTO_JSON_OBJECT(dest, timestamp, response.timestamp);
+ INSERT_INTO_JSON_OBJECT(dest, prev_id, response.prev_id);
+ INSERT_INTO_JSON_OBJECT(dest, nonce, response.nonce);
+ INSERT_INTO_JSON_OBJECT(dest, height, response.height);
+ INSERT_INTO_JSON_OBJECT(dest, depth, response.depth);
+ INSERT_INTO_JSON_OBJECT(dest, hash, response.hash);
+ INSERT_INTO_JSON_OBJECT(dest, difficulty, response.difficulty);
+ INSERT_INTO_JSON_OBJECT(dest, reward, response.reward);
- INSERT_INTO_JSON_OBJECT(val, doc, major_version, response.major_version);
- INSERT_INTO_JSON_OBJECT(val, doc, minor_version, response.minor_version);
- INSERT_INTO_JSON_OBJECT(val, doc, timestamp, response.timestamp);
- INSERT_INTO_JSON_OBJECT(val, doc, prev_id, response.prev_id);
- INSERT_INTO_JSON_OBJECT(val, doc, nonce, response.nonce);
- INSERT_INTO_JSON_OBJECT(val, doc, height, response.height);
- INSERT_INTO_JSON_OBJECT(val, doc, depth, response.depth);
- INSERT_INTO_JSON_OBJECT(val, doc, hash, response.hash);
- INSERT_INTO_JSON_OBJECT(val, doc, difficulty, response.difficulty);
- INSERT_INTO_JSON_OBJECT(val, doc, reward, response.reward);
+ dest.EndObject();
}
void fromJsonValue(const rapidjson::Value& val, cryptonote::rpc::BlockHeaderResponse& response)
@@ -978,34 +1029,36 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::rpc::BlockHeaderResp
GET_FROM_JSON_OBJECT(val, response.reward, reward);
}
-void toJsonValue(rapidjson::Document& doc, const rct::rctSig& sig, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const rct::rctSig& sig)
{
using boost::adaptors::transform;
- val.SetObject();
+ dest.StartObject();
const auto just_mask = [] (rct::ctkey const& key) -> rct::key const&
{
return key.mask;
};
- INSERT_INTO_JSON_OBJECT(val, doc, type, sig.type);
- INSERT_INTO_JSON_OBJECT(val, doc, encrypted, sig.ecdhInfo);
- INSERT_INTO_JSON_OBJECT(val, doc, commitments, transform(sig.outPk, just_mask));
- INSERT_INTO_JSON_OBJECT(val, doc, fee, sig.txnFee);
+ INSERT_INTO_JSON_OBJECT(dest, type, sig.type);
+ INSERT_INTO_JSON_OBJECT(dest, encrypted, sig.ecdhInfo);
+ INSERT_INTO_JSON_OBJECT(dest, commitments, transform(sig.outPk, just_mask));
+ INSERT_INTO_JSON_OBJECT(dest, fee, sig.txnFee);
// prunable
{
- rapidjson::Value prunable;
- prunable.SetObject();
+ dest.Key("prunable");
+ dest.StartObject();
- INSERT_INTO_JSON_OBJECT(prunable, doc, range_proofs, sig.p.rangeSigs);
- INSERT_INTO_JSON_OBJECT(prunable, doc, bulletproofs, sig.p.bulletproofs);
- INSERT_INTO_JSON_OBJECT(prunable, doc, mlsags, sig.p.MGs);
- INSERT_INTO_JSON_OBJECT(prunable, doc, pseudo_outs, sig.get_pseudo_outs());
+ INSERT_INTO_JSON_OBJECT(dest, range_proofs, sig.p.rangeSigs);
+ INSERT_INTO_JSON_OBJECT(dest, bulletproofs, sig.p.bulletproofs);
+ INSERT_INTO_JSON_OBJECT(dest, mlsags, sig.p.MGs);
+ INSERT_INTO_JSON_OBJECT(dest, pseudo_outs, sig.get_pseudo_outs());
- val.AddMember("prunable", prunable, doc.GetAllocator());
+ dest.EndObject();
}
+
+ dest.EndObject();
}
void fromJsonValue(const rapidjson::Value& val, rct::rctSig& sig)
@@ -1046,12 +1099,12 @@ void fromJsonValue(const rapidjson::Value& val, rct::rctSig& sig)
}
}
-void toJsonValue(rapidjson::Document& doc, const rct::ecdhTuple& tuple, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const rct::ecdhTuple& tuple)
{
- val.SetObject();
-
- INSERT_INTO_JSON_OBJECT(val, doc, mask, tuple.mask);
- INSERT_INTO_JSON_OBJECT(val, doc, amount, tuple.amount);
+ dest.StartObject();
+ INSERT_INTO_JSON_OBJECT(dest, mask, tuple.mask);
+ INSERT_INTO_JSON_OBJECT(dest, amount, tuple.amount);
+ dest.EndObject();
}
void fromJsonValue(const rapidjson::Value& val, rct::ecdhTuple& tuple)
@@ -1065,14 +1118,14 @@ void fromJsonValue(const rapidjson::Value& val, rct::ecdhTuple& tuple)
GET_FROM_JSON_OBJECT(val, tuple.amount, amount);
}
-void toJsonValue(rapidjson::Document& doc, const rct::rangeSig& sig, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const rct::rangeSig& sig)
{
- val.SetObject();
+ dest.StartObject();
- INSERT_INTO_JSON_OBJECT(val, doc, asig, sig.asig);
+ INSERT_INTO_JSON_OBJECT(dest, asig, sig.asig);
+ INSERT_INTO_JSON_OBJECT(dest, Ci, epee::span<const rct::key>{sig.Ci});
- std::vector<rct::key> keyVector(sig.Ci, std::end(sig.Ci));
- INSERT_INTO_JSON_OBJECT(val, doc, Ci, keyVector);
+ dest.EndObject();
}
void fromJsonValue(const rapidjson::Value& val, rct::rangeSig& sig)
@@ -1102,22 +1155,24 @@ void fromJsonValue(const rapidjson::Value& val, rct::rangeSig& sig)
}
}
-void toJsonValue(rapidjson::Document& doc, const rct::Bulletproof& p, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const rct::Bulletproof& p)
{
- val.SetObject();
+ dest.StartObject();
+
+ INSERT_INTO_JSON_OBJECT(dest, V, p.V);
+ INSERT_INTO_JSON_OBJECT(dest, A, p.A);
+ INSERT_INTO_JSON_OBJECT(dest, S, p.S);
+ INSERT_INTO_JSON_OBJECT(dest, T1, p.T1);
+ INSERT_INTO_JSON_OBJECT(dest, T2, p.T2);
+ INSERT_INTO_JSON_OBJECT(dest, taux, p.taux);
+ INSERT_INTO_JSON_OBJECT(dest, mu, p.mu);
+ INSERT_INTO_JSON_OBJECT(dest, L, p.L);
+ INSERT_INTO_JSON_OBJECT(dest, R, p.R);
+ INSERT_INTO_JSON_OBJECT(dest, a, p.a);
+ INSERT_INTO_JSON_OBJECT(dest, b, p.b);
+ INSERT_INTO_JSON_OBJECT(dest, t, p.t);
- INSERT_INTO_JSON_OBJECT(val, doc, V, p.V);
- INSERT_INTO_JSON_OBJECT(val, doc, A, p.A);
- INSERT_INTO_JSON_OBJECT(val, doc, S, p.S);
- INSERT_INTO_JSON_OBJECT(val, doc, T1, p.T1);
- INSERT_INTO_JSON_OBJECT(val, doc, T2, p.T2);
- INSERT_INTO_JSON_OBJECT(val, doc, taux, p.taux);
- INSERT_INTO_JSON_OBJECT(val, doc, mu, p.mu);
- INSERT_INTO_JSON_OBJECT(val, doc, L, p.L);
- INSERT_INTO_JSON_OBJECT(val, doc, R, p.R);
- INSERT_INTO_JSON_OBJECT(val, doc, a, p.a);
- INSERT_INTO_JSON_OBJECT(val, doc, b, p.b);
- INSERT_INTO_JSON_OBJECT(val, doc, t, p.t);
+ dest.EndObject();
}
void fromJsonValue(const rapidjson::Value& val, rct::Bulletproof& p)
@@ -1141,17 +1196,15 @@ void fromJsonValue(const rapidjson::Value& val, rct::Bulletproof& p)
GET_FROM_JSON_OBJECT(val, p.t, t);
}
-void toJsonValue(rapidjson::Document& doc, const rct::boroSig& sig, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const rct::boroSig& sig)
{
- val.SetObject();
-
- std::vector<rct::key> keyVector(sig.s0, std::end(sig.s0));
- INSERT_INTO_JSON_OBJECT(val, doc, s0, keyVector);
+ dest.StartObject();
- keyVector.assign(sig.s1, std::end(sig.s1));
- INSERT_INTO_JSON_OBJECT(val, doc, s1, keyVector);
+ INSERT_INTO_JSON_OBJECT(dest, s0, epee::span<const rct::key>{sig.s0});
+ INSERT_INTO_JSON_OBJECT(dest, s1, epee::span<const rct::key>{sig.s1});
+ INSERT_INTO_JSON_OBJECT(dest, ee, sig.ee);
- INSERT_INTO_JSON_OBJECT(val, doc, ee, sig.ee);
+ dest.EndObject();
}
void fromJsonValue(const rapidjson::Value& val, rct::boroSig& sig)
@@ -1188,12 +1241,14 @@ void fromJsonValue(const rapidjson::Value& val, rct::boroSig& sig)
GET_FROM_JSON_OBJECT(val, sig.ee, ee);
}
-void toJsonValue(rapidjson::Document& doc, const rct::mgSig& sig, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const rct::mgSig& sig)
{
- val.SetObject();
+ dest.StartObject();
- INSERT_INTO_JSON_OBJECT(val, doc, ss, sig.ss);
- INSERT_INTO_JSON_OBJECT(val, doc, cc, sig.cc);
+ INSERT_INTO_JSON_OBJECT(dest, ss, sig.ss);
+ INSERT_INTO_JSON_OBJECT(dest, cc, sig.cc);
+
+ dest.EndObject();
}
void fromJsonValue(const rapidjson::Value& val, rct::mgSig& sig)
@@ -1207,32 +1262,34 @@ void fromJsonValue(const rapidjson::Value& val, rct::mgSig& sig)
GET_FROM_JSON_OBJECT(val, sig.cc, cc);
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::rpc::DaemonInfo& info, rapidjson::Value& val)
-{
- val.SetObject();
-
- INSERT_INTO_JSON_OBJECT(val, doc, height, info.height);
- INSERT_INTO_JSON_OBJECT(val, doc, target_height, info.target_height);
- INSERT_INTO_JSON_OBJECT(val, doc, difficulty, info.difficulty);
- INSERT_INTO_JSON_OBJECT(val, doc, target, info.target);
- INSERT_INTO_JSON_OBJECT(val, doc, tx_count, info.tx_count);
- INSERT_INTO_JSON_OBJECT(val, doc, tx_pool_size, info.tx_pool_size);
- INSERT_INTO_JSON_OBJECT(val, doc, alt_blocks_count, info.alt_blocks_count);
- INSERT_INTO_JSON_OBJECT(val, doc, outgoing_connections_count, info.outgoing_connections_count);
- INSERT_INTO_JSON_OBJECT(val, doc, incoming_connections_count, info.incoming_connections_count);
- INSERT_INTO_JSON_OBJECT(val, doc, white_peerlist_size, info.white_peerlist_size);
- INSERT_INTO_JSON_OBJECT(val, doc, grey_peerlist_size, info.grey_peerlist_size);
- INSERT_INTO_JSON_OBJECT(val, doc, mainnet, info.mainnet);
- INSERT_INTO_JSON_OBJECT(val, doc, testnet, info.testnet);
- INSERT_INTO_JSON_OBJECT(val, doc, stagenet, info.stagenet);
- INSERT_INTO_JSON_OBJECT(val, doc, nettype, info.nettype);
- INSERT_INTO_JSON_OBJECT(val, doc, top_block_hash, info.top_block_hash);
- INSERT_INTO_JSON_OBJECT(val, doc, cumulative_difficulty, info.cumulative_difficulty);
- INSERT_INTO_JSON_OBJECT(val, doc, block_size_limit, info.block_size_limit);
- INSERT_INTO_JSON_OBJECT(val, doc, block_weight_limit, info.block_weight_limit);
- INSERT_INTO_JSON_OBJECT(val, doc, block_size_median, info.block_size_median);
- INSERT_INTO_JSON_OBJECT(val, doc, block_weight_median, info.block_weight_median);
- INSERT_INTO_JSON_OBJECT(val, doc, start_time, info.start_time);
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::rpc::DaemonInfo& info)
+{
+ dest.StartObject();
+
+ INSERT_INTO_JSON_OBJECT(dest, height, info.height);
+ INSERT_INTO_JSON_OBJECT(dest, target_height, info.target_height);
+ INSERT_INTO_JSON_OBJECT(dest, difficulty, info.difficulty);
+ INSERT_INTO_JSON_OBJECT(dest, target, info.target);
+ INSERT_INTO_JSON_OBJECT(dest, tx_count, info.tx_count);
+ INSERT_INTO_JSON_OBJECT(dest, tx_pool_size, info.tx_pool_size);
+ INSERT_INTO_JSON_OBJECT(dest, alt_blocks_count, info.alt_blocks_count);
+ INSERT_INTO_JSON_OBJECT(dest, outgoing_connections_count, info.outgoing_connections_count);
+ INSERT_INTO_JSON_OBJECT(dest, incoming_connections_count, info.incoming_connections_count);
+ INSERT_INTO_JSON_OBJECT(dest, white_peerlist_size, info.white_peerlist_size);
+ INSERT_INTO_JSON_OBJECT(dest, grey_peerlist_size, info.grey_peerlist_size);
+ INSERT_INTO_JSON_OBJECT(dest, mainnet, info.mainnet);
+ INSERT_INTO_JSON_OBJECT(dest, testnet, info.testnet);
+ INSERT_INTO_JSON_OBJECT(dest, stagenet, info.stagenet);
+ INSERT_INTO_JSON_OBJECT(dest, nettype, info.nettype);
+ INSERT_INTO_JSON_OBJECT(dest, top_block_hash, info.top_block_hash);
+ INSERT_INTO_JSON_OBJECT(dest, cumulative_difficulty, info.cumulative_difficulty);
+ INSERT_INTO_JSON_OBJECT(dest, block_size_limit, info.block_size_limit);
+ INSERT_INTO_JSON_OBJECT(dest, block_weight_limit, info.block_weight_limit);
+ INSERT_INTO_JSON_OBJECT(dest, block_size_median, info.block_size_median);
+ INSERT_INTO_JSON_OBJECT(dest, block_weight_median, info.block_weight_median);
+ INSERT_INTO_JSON_OBJECT(dest, start_time, info.start_time);
+
+ dest.EndObject();
}
void fromJsonValue(const rapidjson::Value& val, cryptonote::rpc::DaemonInfo& info)
@@ -1266,14 +1323,16 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::rpc::DaemonInfo& inf
GET_FROM_JSON_OBJECT(val, info.start_time, start_time);
}
-void toJsonValue(rapidjson::Document& doc, const cryptonote::rpc::output_distribution& dist, rapidjson::Value& val)
+void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const cryptonote::rpc::output_distribution& dist)
{
- val.SetObject();
+ dest.StartObject();
+
+ INSERT_INTO_JSON_OBJECT(dest, distribution, dist.data.distribution);
+ INSERT_INTO_JSON_OBJECT(dest, amount, dist.amount);
+ INSERT_INTO_JSON_OBJECT(dest, start_height, dist.data.start_height);
+ INSERT_INTO_JSON_OBJECT(dest, base, dist.data.base);
- INSERT_INTO_JSON_OBJECT(val, doc, distribution, dist.data.distribution);
- INSERT_INTO_JSON_OBJECT(val, doc, amount, dist.amount);
- INSERT_INTO_JSON_OBJECT(val, doc, start_height, dist.data.start_height);
- INSERT_INTO_JSON_OBJECT(val, doc, base, dist.data.base);
+ dest.EndObject();
}
void fromJsonValue(const rapidjson::Value& val, cryptonote::rpc::output_distribution& dist)