/* This file is part of cpp-ethereum. cpp-ethereum is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. cpp-ethereum is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with cpp-ethereum. If not, see . */ /** @file JsonHelper.h * @authors: * Gav Wood * @date 2015 */ #pragma once #include #include #include #include namespace dev { Json::Value toJson(std::map const& _storage); Json::Value toJson(std::unordered_map const& _storage); namespace p2p { Json::Value toJson(PeerSessionInfo const& _p); } namespace eth { class Transaction; struct BlockDetails; class Interface; using Transactions = std::vector; using UncleHashes = h256s; using TransactionHashes = h256s; Json::Value toJson(BlockInfo const& _bi); Json::Value toJson(Transaction const& _t, std::pair _location, BlockNumber _blockNumber); Json::Value toJson(BlockInfo const& _bi, BlockDetails const& _bd, UncleHashes const& _us, Transactions const& _ts); Json::Value toJson(BlockInfo const& _bi, BlockDetails const& _bd, UncleHashes const& _us, TransactionHashes const& _ts); Json::Value toJson(TransactionSkeleton const& _t); Json::Value toJson(Transaction const& _t); Json::Value toJson(TransactionReceipt const& _t); Json::Value toJson(LocalisedLogEntry const& _e); Json::Value toJson(LogEntry const& _e); TransactionSkeleton toTransactionSkeleton(Json::Value const& _json); LogFilter toLogFilter(Json::Value const& _json); LogFilter toLogFilter(Json::Value const& _json, Interface const& _client); // commented to avoid warning. Uncomment once in use @ PoC-7. } namespace shh { Json::Value toJson(h256 const& _h, Envelope const& _e, Message const& _m); Message toMessage(Json::Value const& _json); Envelope toSealed(Json::Value const& _json, Message const& _m, Secret _from); std::pair toWatch(Json::Value const& _json); } template Json::Value toJson(std::vector const& _es) { Json::Value res(Json::arrayValue); for (auto const& e: _es) res.append(toJson(e)); return res; } template Json::Value toJson(std::unordered_set const& _es) { Json::Value res(Json::arrayValue); for (auto const& e: _es) res.append(toJson(e)); return res; } template Json::Value toJson(std::set const& _es) { Json::Value res(Json::arrayValue); for (auto const& e: _es) res.append(toJson(e)); return res; } }