Skip to content

Commit

Permalink
json: move impl out of header
Browse files Browse the repository at this point in the history
Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
  • Loading branch information
dotnwat committed Mar 26, 2024
1 parent 432cfb0 commit 20dcf97
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
18 changes: 18 additions & 0 deletions src/v/json/json.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,22 @@ void rjson_serialize(
rjson_serialize(w, std::string_view{path.native()});
}

ss::sstring minify(std::string_view json) {
json::Reader r;
json::StringStream in(json.data());
json::StringBuffer out;
json::Writer<json::StringBuffer> w{out};
r.Parse(in, w);
return ss::sstring(out.GetString(), out.GetSize());
}

ss::sstring prettify(std::string_view json) {
json::Reader r;
json::StringStream in(json.data());
json::StringBuffer out;
json::PrettyWriter<json::StringBuffer> w{out};
r.Parse(in, w);
return ss::sstring(out.GetString(), out.GetSize());
}

} // namespace json
18 changes: 2 additions & 16 deletions src/v/json/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,8 @@ void rjson_serialize(
w.EndArray();
}

inline ss::sstring minify(std::string_view json) {
json::Reader r;
json::StringStream in(json.data());
json::StringBuffer out;
json::Writer<json::StringBuffer> w{out};
r.Parse(in, w);
return ss::sstring(out.GetString(), out.GetSize());
}
ss::sstring minify(std::string_view json);

inline ss::sstring prettify(std::string_view json) {
json::Reader r;
json::StringStream in(json.data());
json::StringBuffer out;
json::PrettyWriter<json::StringBuffer> w{out};
r.Parse(in, w);
return ss::sstring(out.GetString(), out.GetSize());
}
ss::sstring prettify(std::string_view json);

} // namespace json

0 comments on commit 20dcf97

Please sign in to comment.