From 4e2377995d286eb01456ed1dfd29cd278282ec19 Mon Sep 17 00:00:00 2001 From: Lee Clagett Date: Sun, 31 May 2020 01:22:33 -0400 Subject: Change ZMQ-JSON txextra to hex and remove unnecessary base fields --- src/serialization/json_object.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/serialization/json_object.h') diff --git a/src/serialization/json_object.h b/src/serialization/json_object.h index 2a9b63b08..9f652a679 100644 --- a/src/serialization/json_object.h +++ b/src/serialization/json_object.h @@ -153,6 +153,9 @@ inline void toJsonValue(rapidjson::Writer& dest, const std::s } void fromJsonValue(const rapidjson::Value& val, std::string& str); +void toJsonValue(rapidjson::Writer& dest, const std::vector&); +void fromJsonValue(const rapidjson::Value& src, std::vector& i); + void toJsonValue(rapidjson::Writer& dest, bool i); void fromJsonValue(const rapidjson::Value& val, bool& b); @@ -353,6 +356,10 @@ inline typename std::enable_if::value, void>::type from template inline typename std::enable_if::value, void>::type toJsonValue(rapidjson::Writer& dest, const Vec &vec) { + using value_type = typename Vec::value_type; + static_assert(!std::is_same::value, "encoding an array of chars is faster as hex"); + static_assert(!std::is_same::value, "encoding an array of unsigned char is faster as hex"); + dest.StartArray(); for (const auto& t : vec) toJsonValue(dest, t); @@ -362,6 +369,10 @@ inline typename std::enable_if::value, void>::type t template inline typename std::enable_if::value, void>::type fromJsonValue(const rapidjson::Value& val, Vec& vec) { + using value_type = typename Vec::value_type; + static_assert(!std::is_same::value, "encoding a vector of chars is faster as hex"); + static_assert(!std::is_same::value, "encoding a vector of unsigned char is faster as hex"); + if (!val.IsArray()) { throw WRONG_TYPE("json array"); -- cgit v1.2.3