mirror of
https://github.com/XRPLF/rippled.git
synced 2026-10-25 04:57:11 +00:00
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: mvadari <[email protected]> Co-authored-by: Mayukha Vadari <[email protected]> Co-authored-by: Ayaz Salikhov <[email protected]> Co-authored-by: xrplf-ai-reviewer[bot] <266832837+xrplf-ai-reviewer[bot]@users.noreply.github.com> Co-authored-by: Mayukha Vadari <[email protected]> Co-authored-by: Timur Yalymov <[email protected]> Co-authored-by: Cursor <[email protected]> Co-authored-by: Vito Tumas <[email protected]>
38 lines
830 B
C++
38 lines
830 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
|