mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
Agent-Logs-Url: https://github.com/XRPLF/rippled/sessions/3aef40d0-f51b-484c-a5d3-43dd37d6187f Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
36 lines
824 B
C++
36 lines
824 B
C++
#pragma once
|
|
|
|
#include <functional>
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
namespace Json {
|
|
|
|
class Value;
|
|
|
|
using Output = std::function<void(std::string_view)>;
|
|
|
|
inline Output
|
|
stringOutput(std::string& s)
|
|
{
|
|
return [&](std::string_view b) { s.append(b.data(), b.size()); };
|
|
}
|
|
|
|
/** Writes a minimal representation of a Json value to an Output in O(n) time.
|
|
|
|
Data is streamed right to the output, so only a marginal amount of memory is
|
|
used. This can be very important for a very large Json::Value.
|
|
*/
|
|
void
|
|
outputJson(Json::Value const&, Output const&);
|
|
|
|
/** Return the minimal string representation of a Json::Value in O(n) time.
|
|
|
|
This requires a memory allocation for the full size of the output.
|
|
If possible, use outputJson().
|
|
*/
|
|
std::string
|
|
jsonAsString(Json::Value const&);
|
|
|
|
} // namespace Json
|