Zig
Zig
Create JSON Array of Strings
See more JSON Examples
Demonstrates how to create a JSON array of strings.Chilkat Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
// The goal of this example is to produce this:
// [
// "tag1",
// "tag2",
// "tag3"
// ]
const jarr = try chilkat.JsonArray.init();
defer jarr.deinit();
jarr.addStringAt(-1, "tag1") catch {};
jarr.addStringAt(-1, "tag2") catch {};
jarr.addStringAt(-1, "tag3") catch {};
jarr.setEmitCompact(false);
std.debug.print("{s}\n", .{try jarr.emit(alloc)});
}