Zig
Zig
JSON Append String Array
See more JSON Examples
Demonstrates how to append an array of strings from a string table object.Note: This example uses the AppendStringTable method, which was introduced in Chilkat v9.5.0.67
Chilkat Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
const json = try chilkat.JsonObject.init();
defer json.deinit();
json.setEmitCompact(false);
json.appendString("abc", "123") catch {};
const st = try chilkat.StringTable.init();
defer st.deinit();
st.append("a") catch {};
st.append("b") catch {};
st.append("c") catch {};
st.append("d") catch {};
json.appendStringArray("strArray", st) catch {};
std.debug.print("{s}\n", .{try json.emit(alloc)});
// Output:
// {
// "abc": "123",
// "strArray": [
// "a",
// "b",
// "c",
// "d"
// ]
// }
}