SilentJSON Quickstart Example
July 1, 2026 ยท View on GitHub
This directory contains a basic example demonstrating the core features of silentjson.
It covers two primary use cases:
- Parallel Unmarshaling: Reading an entire JSON array into memory extremely fast using
UnmarshalArrayParallel. - Stream Parsing: Reading a JSON array from an
io.ReaderusingNewStreamDecoderand iterating over it withNext().
How to run
go run main.go
What you will learn
- Registry Initialization: How to use
silentjson.BuildRegistry(reflect.TypeOf(...))once at the application startup to avoid reflection overhead during actual parsing. - Zero-Allocation Slices: Why
silentjsonrequires you to provide a pre-allocated slice (e.g.,make([]Employee, 2)). - Streaming Iterator: How
decoder.Next()reuses a single struct pointer inside the callback, ensuring zero allocations during streaming.