11#include <userver/formats/json/value.hpp>
12#include <userver/utils/fast_pimpl.hpp>
13#include <userver/utils/fmt_compat.hpp>
15USERVER_NAMESPACE_BEGIN
25constexpr inline std::size_t kDepthParseLimit = 128;
47struct PrettyFormat
final {
48 char indent_char{
' '};
49 std::size_t indent_char_count{2};
67class StringBuffer
final {
69 explicit StringBuffer(
const formats::
json::Value& value);
72 std::string_view GetStringView()
const;
76 static constexpr std::size_t kSize = 48;
77 static constexpr std::size_t kAlignment = 8;
78 utils::FastPimpl<Impl, kSize, kAlignment> pimpl_;
88struct fmt::formatter<USERVER_NAMESPACE::formats::json::Value> : fmt::formatter<std::string_view> {
89 constexpr static auto parse(format_parse_context& ctx) ->
decltype(ctx.begin()) {
return ctx.begin(); }
91 template <
typename FormatContext>
92 auto format(
const USERVER_NAMESPACE::formats::json::Value& value, FormatContext& ctx)
94 const USERVER_NAMESPACE::formats::json::impl::StringBuffer buffer(value);
95 return formatter<string_view>::format(buffer.GetStringView(), ctx);