| ... | ... | @@ -138,13 +138,13 @@ pub fn WriteStream(comptime OutStream: type, comptime max_depth: usize) type { |
| 138 | 138 | |
| 139 | 139 | pub fn emitNull(self: *Self) !void { |
| 140 | 140 | assert(self.state[self.state_index] == State.Value); |
| 141 | | try self.stream.writeAll("null"); |
| 141 | try self.stringify(null); |
| 142 | 142 | self.popState(); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | pub fn emitBool(self: *Self, value: bool) !void { |
| 146 | 146 | assert(self.state[self.state_index] == State.Value); |
| 147 | | try std.json.stringify(value, std.json.StringifyOptions{}, self.stream); |
| 147 | try self.stringify(value); |
| 148 | 148 | self.popState(); |
| 149 | 149 | } |
| 150 | 150 | |
| ... | ... | @@ -186,14 +186,12 @@ pub fn WriteStream(comptime OutStream: type, comptime max_depth: usize) type { |
| 186 | 186 | |
| 187 | 187 | fn writeEscapedString(self: *Self, string: []const u8) !void { |
| 188 | 188 | assert(std.unicode.utf8ValidateSlice(string)); |
| 189 | | try std.json.stringify(string, std.json.StringifyOptions{}, self.stream); |
| 189 | try self.stringify(string); |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | /// Writes the complete json into the output stream |
| 193 | 193 | pub fn emitJson(self: *Self, json: std.json.Value) Stream.Error!void { |
| 194 | | try json.jsonStringify(std.json.StringifyOptions{ |
| 195 | | .whitespace = self.whitespace, |
| 196 | | }, self.stream); |
| 194 | try self.stringify(json); |
| 197 | 195 | } |
| 198 | 196 | |
| 199 | 197 | fn indent(self: *Self) !void { |
| ... | ... | @@ -210,6 +208,12 @@ pub fn WriteStream(comptime OutStream: type, comptime max_depth: usize) type { |
| 210 | 208 | fn popState(self: *Self) void { |
| 211 | 209 | self.state_index -= 1; |
| 212 | 210 | } |
| 211 | |
| 212 | fn stringify(self: *Self, value: var) !void { |
| 213 | try std.json.stringify(value, std.json.StringifyOptions{ |
| 214 | .whitespace = self.whitespace, |
| 215 | }, self.stream); |
| 216 | } |
| 213 | 217 | }; |
| 214 | 218 | } |
| 215 | 219 | |