diff options
author | Lee Clagett <code@leeclagett.com> | 2019-11-17 04:30:19 +0000 |
---|---|---|
committer | Lee Clagett <code@leeclagett.com> | 2020-03-09 17:55:55 +0000 |
commit | 3387f0e327cb817c5f7f7f4c3d5dcc4990747cd1 (patch) | |
tree | cd1eb07c5e44cc1b5310aa5224493fbca1dea816 /src/serialization/json_object.cpp | |
parent | Move hex->bin conversion to monero copyright files and with less includes (diff) | |
download | monero-3387f0e327cb817c5f7f7f4c3d5dcc4990747cd1.tar.xz |
Reduce template bloat in hex->bin for ZMQ json
Diffstat (limited to 'src/serialization/json_object.cpp')
-rw-r--r-- | src/serialization/json_object.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/serialization/json_object.cpp b/src/serialization/json_object.cpp index e98ba0483..926eb18c0 100644 --- a/src/serialization/json_object.cpp +++ b/src/serialization/json_object.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2019, The Monero Project +// Copyright (c) 2016-2020, The Monero Project // // All rights reserved. // @@ -32,7 +32,11 @@ #include <boost/variant/apply_visitor.hpp> #include <limits> #include <type_traits> -#include "string_tools.h" + +// drop macro from windows.h +#ifdef GetObject + #undef GetObject +#endif namespace cryptonote { @@ -109,6 +113,19 @@ namespace } } +void read_hex(const rapidjson::Value& val, epee::span<std::uint8_t> dest) +{ + if (!val.IsString()) + { + throw WRONG_TYPE("string"); + } + + if (!epee::from_hex::to_buffer(dest, {val.GetString(), val.Size()})) + { + throw BAD_INPUT(); + } +} + void toJsonValue(rapidjson::Writer<rapidjson::StringBuffer>& dest, const rapidjson::Value& src) { src.Accept(dest); |