I am trying to use JSON in zig and I don't understand why this doesn't compile:
const file = std.fs.cwd().createFile("Hello", .{.read = true}) catch unreachable;
const stream = std.json.writeStream(std.fs.File.Writer, 5000000);
_ = stream;
The error:
error: parameter of type 'type' must be declared comptime
pub fn init(stream: OutStream) Self {
std.json.writeStream
wants an instance of a write stream, you should pass to it file.writer()
instead of std.fs.File.Writer
.