Getty JSON is a (de)serialization library for the JSON data format.
-
Declare Getty JSON as a project dependency with
zig fetch
:zig fetch --save git+https://github.com/getty-zig/json.git#<COMMIT>
-
Expose Getty JSON as a module in your project's
build.zig
:pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const opts = .{ .target = target, .optimize = optimize }; // 👈 const json_mod = b.dependency("json", opts).module("json"); // 👈 const exe = b.addExecutable(.{ .name = "my-project", .root_source_file = .{ .path = "src/main.zig" }, .target = target, .optimize = optimize, }); exe.root_module.addImport("json", json_mod); // 👈 // ... }
-
Import Getty JSON into your code:
const json = @import("json");