{"id":22123081,"url":"https://github.com/bcrist/zig-sx","last_synced_at":"2025-07-12T03:41:45.346Z","repository":{"id":150150004,"uuid":"555178463","full_name":"bcrist/Zig-SX","owner":"bcrist","description":"S-Expression [de]serialization in Zig","archived":false,"fork":false,"pushed_at":"2025-03-22T07:10:59.000Z","size":175,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-22T08:19:59.362Z","etag":null,"topics":["encoding","s-expression","s-expressions","sexp","zig","zig-library","zig-package","ziglang"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bcrist.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-21T04:46:37.000Z","updated_at":"2025-03-22T07:11:02.000Z","dependencies_parsed_at":"2024-04-26T05:25:59.096Z","dependency_job_id":"2fc50307-c3c4-4c6c-b2c7-d1279b521634","html_url":"https://github.com/bcrist/Zig-SX","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcrist%2FZig-SX","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcrist%2FZig-SX/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcrist%2FZig-SX/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcrist%2FZig-SX/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bcrist","download_url":"https://codeload.github.com/bcrist/Zig-SX/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245226722,"owners_count":20580736,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["encoding","s-expression","s-expressions","sexp","zig","zig-library","zig-package","ziglang"],"created_at":"2024-12-01T15:29:10.233Z","updated_at":"2025-03-24T07:28:02.041Z","avatar_url":"https://github.com/bcrist.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Zig-SX\n\nA simple Zig library for reading and writing S-Expressions.\n\nIdeal for human-readable configuration or data files containing lots of compound structures.\n\nParsing and writing is always done interactively with the user program; there is no intermediate \"document\" representation.\n\n## Reader Example\n```zig\nconst std = @import(\"std\");\nconst sx = @import(\"sx\");\n\nvar source =\n    \\\\(box my-box\n    \\\\    (dimensions  4.3   7    14)\n    \\\\    (color red)\n    \\\\    (contents\n    \\\\        42\n    \\\\        \"Big Phil's To Do List:\n    \\\\ - paint it black\n    \\\\ - clean up around the house\n    \\\\\")\n    \\\\)\n    \\\\\n;\n\nvar stream = std.io.fixedBufferStream(source);\nvar reader = sx.reader(std.testing.allocator, stream.reader());\ndefer reader.deinit();\n\ntry reader.require_expression(\"box\");\n_ = try reader.require_any_string();\nvar color: []const u8 = \"\";\nvar width: f32 = 0;\nvar depth: f32 = 0;\nvar height: f32 = 0;\n\nwhile (try reader.any_expression()) |expr| {\n    if (std.mem.eql(u8, expr, \"dimensions\")) {\n        width = try reader.require_any_float(f32);\n        depth = try reader.require_any_float(f32);\n        height = try reader.require_any_float(f32);\n        try reader.require_close();\n\n    } else if (std.mem.eql(u8, expr, \"color\")) {\n        color = try std.testing.allocator.dupe(u8, try reader.require_any_string());\n        try reader.require_close();\n\n    } else if (std.mem.eql(u8, expr, \"contents\")) {\n        while (try reader.any_string()) |contents| {\n            std.debug.print(\"Phil's box contains: {s}\\n\", .{ contents });\n        }\n        try reader.require_close();\n\n    } else {\n        try reader.ignore_remaining_expression();\n    }\n}\ntry reader.require_close();\ntry reader.require_done();\n```\n\n## Writer Example\n```zig\nconst std = @import(\"std\");\nconst sx = @import(\"sx\");\n\nvar writer = sx.writer(std.testing.allocator, std.io.getStdOut().writer());\ndefer writer.deinit();\n\ntry writer.expression(\"box\");\ntry writer.string(\"my-box\");\nwriter.set_compact(false);\n\ntry writer.expression(\"dimensions\");\ntry writer.float(4.3);\ntry writer.float(7);\ntry writer.float(14);\n_ = try writer.close();\n\ntry writer.expression(\"color\");\ntry writer.string(\"red\");\n_ = try writer.close();\n\ntry writer.expression_expanded(\"contents\");\ntry writer.int(42, 10);\ntry writer.string(\n    \\\\Big Phil's To Do List:\n    \\\\ - paint it black\n    \\\\ - clean up around the house\n    \\\\\n);\n\ntry writer.done();\n```\n\n## Building\nThis library is designed to be used with the Zig package manager.  To use it, add a `build.zig.zon` file next to your `build.zig` file:\n```zig\n.{\n    .name = \"Your Project Name\",\n    .version = \"0.0.0\",\n    .dependencies = .{\n        .@\"Zig-SX\" = .{\n            .url = \"https://github.com/bcrist/Zig-SX/archive/xxxxxx.tar.gz\",\n        },\n    },\n}\n```\nReplace `xxxxxx` with the full commit hash for the version of the library you want to use.  The first time you run `zig build` after adding this, it will tell you a hash to put after `.url = ...`.  This helps zig ensure that the file wasn't corrupted during download, and that the URL hasn't been hijacked.\nThen in your `build.zig` file you can get a reference to the package:\n```zig\nconst zig_sx = b.dependency(\"Zig-SX\", .{});\nconst exe = b.addExecutable(.{\n    .name = \"my_exe_name\",\n    .root_source_file = .{ .path = \"my_main_file.zig\" },\n    .target = b.standardTargetOptions(.{}),\n    .optimize = b.standardOptimizeOption(.{}),\n});\nexe.addModule(\"sx\", zig_sx.module(\"sx\"));\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcrist%2Fzig-sx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbcrist%2Fzig-sx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcrist%2Fzig-sx/lists"}