Начало фикса json

This commit is contained in:
2026-03-02 17:19:55 +03:00
parent b692539a30
commit 8ea5d97c2d
12 changed files with 55 additions and 58 deletions

View File

@@ -18,12 +18,13 @@ pub fn saveToFile(doc: *const Document, path: []const u8) !void {
var buffer: [4096]u8 = undefined;
var writer = file.writer(&buffer);
var jw: std.json.Stringify = .{
.writer = &writer.interface,
.options = .{ .whitespace = .indent_2 },
};
try writeDocument(&jw, doc);
try std.json.Stringify.value(
doc,
.{ .whitespace = .indent_2 },
&writer.interface,
);
try writer.interface.flush();
}
@@ -158,11 +159,10 @@ fn parseDocumentValue(allocator: std.mem.Allocator, value: std.json.Value) !Docu
var document = Document{
.size = size,
.allocator = allocator,
.objects = std.ArrayList(Object).empty,
.next_object_id = 1,
};
errdefer document.deinit();
errdefer document.deinit(allocator);
const objects_val = try getField(obj, "objects");
const objects_arr = try expectArray(objects_val);