11#include <userver/formats/json/value.hpp>
12#include <userver/utils/fast_pimpl.hpp>
13#include <userver/utils/fmt_compat.hpp>
15USERVER_NAMESPACE_BEGIN
23namespace formats::
json {
41std::string ToStableString(formats::
json::Value&& doc);
45 const formats::
json::Value&);
56class StringBuffer final {
58 explicit StringBuffer(
const formats::json::Value& value);
61 std::string_view GetStringView()
const;
65 static constexpr std::size_t kSize = 48;
66 static constexpr std::size_t kAlignment = 8;
67 utils::FastPimpl<Impl, kSize, kAlignment> pimpl_;
77struct fmt::formatter<USERVER_NAMESPACE::formats::json::Value>
78 : fmt::formatter<std::string_view> {
79 constexpr static auto parse(format_parse_context& ctx)
80 ->
decltype(ctx.begin()) {
84 template <
typename FormatContext>
85 auto format(
const USERVER_NAMESPACE::formats::json::Value& value,
87 const USERVER_NAMESPACE::formats::json::impl::StringBuffer buffer(value);
88 return formatter<string_view>::format(buffer.GetStringView(), ctx);