Use json value_to<string> to do the string convert (#1172)

Fix #953
This commit is contained in:
cyan317
2024-02-14 13:26:00 +00:00
committed by GitHub
parent cce695c570
commit b89cdb26f2
44 changed files with 299 additions and 217 deletions

View File

@@ -26,6 +26,7 @@
#include <boost/json/conversion.hpp>
#include <boost/json/value.hpp>
#include <boost/json/value_to.hpp>
#include <ripple/basics/base_uint.h>
#include <ripple/basics/chrono.h>
#include <ripple/basics/strHex.h>
@@ -102,16 +103,16 @@ tag_invoke(boost::json::value_to_tag<TransactionEntryHandler::Input>, boost::jso
auto input = TransactionEntryHandler::Input{};
auto const& jsonObject = jv.as_object();
input.txHash = jv.at(JS(tx_hash)).as_string().c_str();
input.txHash = boost::json::value_to<std::string>(jv.at(JS(tx_hash)));
if (jsonObject.contains(JS(ledger_hash)))
input.ledgerHash = jv.at(JS(ledger_hash)).as_string().c_str();
input.ledgerHash = boost::json::value_to<std::string>(jv.at(JS(ledger_hash)));
if (jsonObject.contains(JS(ledger_index))) {
if (!jsonObject.at(JS(ledger_index)).is_string()) {
input.ledgerIndex = jv.at(JS(ledger_index)).as_int64();
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
input.ledgerIndex = std::stoi(jv.at(JS(ledger_index)).as_string().c_str());
input.ledgerIndex = std::stoi(boost::json::value_to<std::string>(jv.at(JS(ledger_index))));
}
}