commit 5a053247e2c5cfb21af2dfdd3d7ffa56c33f7b67 (tree)
parent e88543a504af4808a3ab7ee169d4b17faa645e5b
Author: daurnimator <quae@daurnimator.com>
Date: Tue, 25 Feb 2020 01:36:30 +1100
std: use stringify from Value.dump; remove other dump helpers
Diffstat:
1 file changed, 1 insertion(+), 29 deletions(-)
diff --git a/lib/std/json.zig b/lib/std/json.zig
@@ -1289,35 +1289,7 @@ pub const Value = union(enum) {
defer held.release();
const stderr = std.debug.getStderrStream();
- self.dumpStream(stderr, 1024) catch return;
- }
-
- pub fn dumpIndent(self: Value, comptime indent: usize) void {
- if (indent == 0) {
- self.dump();
- } else {
- var held = std.debug.getStderrMutex().acquire();
- defer held.release();
-
- const stderr = std.debug.getStderrStream();
- self.dumpStreamIndent(indent, stderr, 1024) catch return;
- }
- }
-
- pub fn dumpStream(self: @This(), stream: var, comptime max_depth: usize) !void {
- var w = std.json.WriteStream(@TypeOf(stream).Child, max_depth).init(stream);
- w.newline = "";
- w.one_indent = "";
- w.space = "";
- try w.emitJson(self);
- }
-
- pub fn dumpStreamIndent(self: @This(), comptime indent: usize, stream: var, comptime max_depth: usize) !void {
- var one_indent = " " ** indent;
-
- var w = std.json.WriteStream(@TypeOf(stream).Child, max_depth).init(stream);
- w.one_indent = one_indent;
- try w.emitJson(self);
+ std.json.stringify(self, std.json.StringifyOptions{ .whitespace = null }, stderr) catch return;
}
};