This folder contains both native Zig examples and browser-oriented wasm examples.
The native examples show the core typed API across the supported formats. The wasm examples show how to move typed data across a JS boundary or parse foreign payloads inside the module.
Build them all with:
zig build examplesThat produces native executables and .wasm artifacts in zig-out/bin/.
Native examples in this folder:
json_roundtrip.zig: serialize a Zig struct to JSON and parse it backtoml_roundtrip.zig: serialize a Zig struct to TOML and parse it backyaml_roundtrip.zig: serialize a Zig struct to YAML and parse it backcbor_roundtrip.zig: serialize a Zig struct to CBOR and parse it backbson_roundtrip.zig: serialize a Zig struct to BSON and parse it backmsgpack_roundtrip.zig: serialize a Zig struct to MessagePack and parse it backzon_roundtrip.zig: serialize a Zig struct to ZON and parse it backbin_roundtrip.zig: serialize a Zig struct tozerde's compact binary format and parse it back
WASM examples in this folder export the same host-facing helpers:
alloc_input(len)to reserve wasm memory for incoming bytesfree_input(ptr, len)to release that input bufferoutput_ptr()andoutput_len()to expose the last successful output bufferrelease_output()to free that output buffer
Examples in this folder:
wasm_bin_bridge.zig: serialize a Zig struct for JS and read compact binary back into wasmwasm_json_bridge.zig: parse JSON inside wasm and reserialize it to canonical JSONwasm_zon_bridge.zig: parse ZON inside wasm and reserialize it to canonical ZONwasm_yaml_bridge.zig: parse YAML inside wasm and reserialize it to JSONwasm_msgpack_bridge.zig: parse MessagePack inside wasm and reserialize it to JSON